added plugin support

This commit is contained in:
Spencer Alger
2015-05-13 00:10:01 -05:00
parent 0dfe5d2634
commit 88bae9e055
16 changed files with 375 additions and 186 deletions

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = <%= stringify(namespaces) %>;<%
@ -9,12 +11,9 @@ _.each(actions, function (action) {
var namespace = action.location.split('.').shift();
if (_.contains(namespaces, namespace)) {
_.pull(namespaces, namespace);
var className = _.studlyCase(namespace) + 'NS';
%>
api.<%= namespace %> = function <%= className %>(transport) {
this.transport = transport;
};<%
api.<%= namespace %> = namespace();<%
}%>
<%= partials.client_action(action) %><%

View File

@ -9,7 +9,7 @@ _.each(allParams, function(param, paramName) { %>
}
%><% }) %>
*/
api<%= (location[0] === '[' ? '' : '.') + location %> = ca.proxy(<%= 'api' + (proxy[0] === '[' ? '' : '.') + proxy %><%
api<%= (location[0] === '[' ? '' : '.') + location %> = proxy(<%= 'api' + (proxy[0] === '[' ? '' : '.') + proxy %><%
if (typeof transformBody === 'string') { %>, {
transform: function (params) {
<%= indent(transformBody, 4) %>

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cluster', 'indices'];
@ -91,9 +93,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/cluster-update-settings.html) request
@ -1145,9 +1145,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/indices-analyze.html) request
@ -3263,7 +3261,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -630,9 +630,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html) request
@ -1666,9 +1664,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-analyze.html) request
@ -3989,9 +3985,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html) request
@ -4754,9 +4748,7 @@ api.searchShards = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html) request
@ -5231,7 +5223,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -662,9 +662,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html) request
@ -1712,9 +1710,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-analyze.html) request
@ -4084,9 +4080,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html) request
@ -4886,9 +4880,7 @@ api.searchShards = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html) request
@ -5406,7 +5398,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -722,9 +722,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html) request
@ -1767,9 +1765,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-analyze.html) request
@ -4096,9 +4092,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html) request
@ -4947,9 +4941,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html) request
@ -5465,7 +5457,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -760,9 +760,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.3/cluster-update-settings.html) request
@ -1883,9 +1881,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.3/indices-analyze.html) request
@ -4217,9 +4213,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.3/cluster-nodes-hot-threads.html) request
@ -5115,9 +5109,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.3/modules-snapshots.html) request
@ -5633,7 +5625,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -760,9 +760,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-update-settings.html) request
@ -1969,9 +1967,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/indices-analyze.html) request
@ -4537,9 +4533,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-nodes-hot-threads.html) request
@ -5615,9 +5609,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/modules-snapshots.html) request
@ -6194,7 +6186,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -760,9 +760,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html) request
@ -2000,9 +1998,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-analyze.html) request
@ -4570,9 +4566,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html) request
@ -5648,9 +5642,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html) request
@ -6219,7 +6211,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -77,9 +79,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -760,9 +760,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elastic.co/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html) request
@ -1095,6 +1093,13 @@ api.cluster.prototype.stats = ca({
* @param {Number} params.minScore - Include only documents with a specific `_score` value in the result
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.routing - Specific routing value
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the results
* @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the results
*/
@ -1128,6 +1133,35 @@ api.count = ca({
},
routing: {
type: 'string'
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -2046,9 +2080,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/1.x/indices-analyze.html) request
@ -4123,6 +4155,12 @@ api.indices.prototype.upgrade = ca({
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {Anything} params.operationThreading - TODO: ?
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
*/
@ -4155,6 +4193,32 @@ api.indices.prototype.validateQuery = ca({
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -4593,9 +4657,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elastic.co/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html) request
@ -5429,6 +5491,13 @@ api.search = ca({
* @param {Number} params.minScore - Include only documents with a specific `_score` value in the result
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.routing - Specific routing value
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the results
* @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the results
*/
@ -5462,6 +5531,35 @@ api.searchExists = ca({
},
routing: {
type: 'string'
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -5646,9 +5744,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elastic.co/guide/en/elasticsearch/reference/1.x/modules-snapshots.html) request
@ -6209,7 +6305,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -1,6 +1,8 @@
/* jshint maxlen: false */
var ca = require('../client_action');
var ca = require('../client_action').factory;
var proxy = require('../client_action').proxyFactory;
var namespace = require('../client_action').namespaceFactory;
var api = module.exports = {};
api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot'];
@ -68,9 +70,7 @@ api.bulk = ca({
method: 'POST'
});
api.cat = function CatNS(transport) {
this.transport = transport;
};
api.cat = namespace();
/**
* Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request
@ -751,9 +751,7 @@ api.clearScroll = ca({
method: 'DELETE'
});
api.cluster = function ClusterNS(transport) {
this.transport = transport;
};
api.cluster = namespace();
/**
* Perform a [cluster.getSettings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request
@ -1086,6 +1084,13 @@ api.cluster.prototype.stats = ca({
* @param {Number} params.minScore - Include only documents with a specific `_score` value in the result
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.routing - Specific routing value
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the results
* @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the results
*/
@ -1119,6 +1124,35 @@ api.count = ca({
},
routing: {
type: 'string'
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -1915,9 +1949,7 @@ api.index = ca({
method: 'POST'
});
api.indices = function IndicesNS(transport) {
this.transport = transport;
};
api.indices = namespace();
/**
* Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request
@ -3891,6 +3923,12 @@ api.indices.prototype.upgrade = ca({
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {Anything} params.operationThreading - TODO: ?
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
*/
@ -3923,6 +3961,32 @@ api.indices.prototype.validateQuery = ca({
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -4258,9 +4322,7 @@ api.mtermvectors = ca({
method: 'POST'
});
api.nodes = function NodesNS(transport) {
this.transport = transport;
};
api.nodes = namespace();
/**
* Perform a [nodes.hotThreads](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html) request
@ -4960,9 +5022,7 @@ api.search = ca({
type: 'enum',
options: [
'query_then_fetch',
'query_and_fetch',
'dfs_query_then_fetch',
'dfs_query_and_fetch',
'count',
'scan'
],
@ -5066,6 +5126,13 @@ api.search = ca({
* @param {Number} params.minScore - Include only documents with a specific `_score` value in the result
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.routing - Specific routing value
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String, String[], Boolean} params.index - A comma-separated list of indices to restrict the results
* @param {String, String[], Boolean} params.type - A comma-separated list of types to restrict the results
*/
@ -5099,6 +5166,35 @@ api.searchExists = ca({
},
routing: {
type: 'string'
},
q: {
type: 'string'
},
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
}
},
urls: [
@ -5283,9 +5379,7 @@ api.searchTemplate = ca({
method: 'POST'
});
api.snapshot = function SnapshotNS(transport) {
this.transport = transport;
};
api.snapshot = namespace();
/**
* Perform a [snapshot.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request
@ -5870,7 +5964,7 @@ api.update = ca({
* @param {String} params.index - The name of the index
* @param {String} params.type - The type of the document
*/
api.create = ca.proxy(api.index, {
api.create = proxy(api.index, {
transform: function (params) {
params.op_type = 'create';
}

View File

@ -27,6 +27,7 @@
module.exports = Client;
var Transport = require('./transport');
var clientAction = require('./client_action');
var _ = require('./utils');
function Client(config) {
@ -55,20 +56,49 @@ function Client(config) {
this.transport = new Transport(config);
// instantiate the api's namespaces
for (var i = 0; i < this._namespaces.length; i++) {
this[this._namespaces[i]] = new this[this._namespaces[i]](this.transport);
}
_.each(EsApiClient.prototype, function (Fn, prop) {
if (Fn.prototype instanceof clientAction.ApiNamespace) {
this[prop] = new Fn(this.transport);
}
}, this);
delete this._namespaces;
}
EsApiClient.prototype = _.funcEnum(config, 'apiVersion', Client.apis, '1.5');
if (!config.sniffEndpoint && EsApiClient.prototype === Client.apis['0.90']) {
config.sniffEndpoint = '/_cluster/nodes';
}
return new EsApiClient();
var Constructor = EsApiClient;
if (config.plugins) {
Constructor.prototype = _.cloneDeep(Constructor.prototype);
_.each(config.plugins, function (setup) {
Constructor = setup(Constructor, config, {
apis: require('./apis'),
connectors: require('./connectors'),
loggers: require('./loggers'),
selectors: require('./selectors'),
serializers: require('./serializers'),
Client: require('./client'),
clientAction: clientAction,
Connection: require('./connection'),
ConnectionPool: require('./connection_pool'),
Errors: require('./errors'),
Host: require('./host'),
Log: require('./log'),
Logger: require('./logger'),
NodesToHost: require('./nodes_to_host'),
Transport: require('./transport'),
utils: require('./utils')
}) || Constructor;
});
}
return new Constructor();
}
Client.apis = require('./apis');

View File

@ -1,12 +1,33 @@
/**
* Constructs a function that can be called to make a request to ES
* @type {[type]}
* @type {Function}
*/
module.exports = ClientAction;
exports.factory = factory;
/**
* Constructs a proxy to another api method
* @type {Function}
*/
exports.proxyFactory = proxyFactory;
// export so that we can test this
exports._resolveUrl = resolveUrl;
exports.ApiNamespace = function() {};
exports.namespaceFactory = function () {
function ClientNamespace(transport) {
this.transport = transport;
}
ClientNamespace.prototype = new exports.ApiNamespace();
return ClientNamespace;
};
var _ = require('./utils');
function ClientAction(spec) {
function factory(spec) {
if (!_.isPlainObject(spec.params)) {
spec.params = {};
}
@ -42,6 +63,24 @@ function ClientAction(spec) {
return action;
}
function proxyFactory(fn, spec) {
return function (params, cb) {
if (typeof params === 'function') {
cb = params;
params = {};
} else {
params = params || {};
cb = typeof cb === 'function' ? cb : null;
}
if (spec.transform) {
spec.transform(params);
}
return fn.call(this, params, cb);
};
}
var castType = {
'enum': function validSelection(param, val, name) {
if (_.isString(val) && val.indexOf(',') > -1) {
@ -188,8 +227,6 @@ function resolveUrl(url, params) {
}, {}));
}
// export so that we can test this
ClientAction.resolveUrl = resolveUrl;
function exec(transport, spec, params, cb) {
var request = {
@ -305,23 +342,4 @@ function commaSepList(str) {
return str.split(',').map(function (i) {
return i.trim();
});
}
ClientAction.proxy = function (fn, spec) {
return function (params, cb) {
if (typeof params === 'function') {
cb = params;
params = {};
} else {
params = params || {};
cb = typeof cb === 'function' ? cb : null;
}
if (spec.transform) {
spec.transform(params);
}
return fn.call(this, params, cb);
};
};
}

View File

@ -161,6 +161,7 @@ _.each(statusCodes, function (name, status) {
}, '') || msg.reason;
}
this.status = status;
ErrorAbstract.call(this, msg || name, StatusCodeError);
}

View File

@ -0,0 +1,4 @@
module.exports = {
angular: require('./angular'),
json: require('./json')
};

View File

@ -91,10 +91,7 @@ Transport.connectionPools = {
main: require('./connection_pool')
};
Transport.serializers = {
json: require('./serializers/json'),
angular: require('./serializers/angular')
};
Transport.serializers = require('./serializers');
Transport.nodesToHostCallbacks = {
main: require('./nodes_to_host')