mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* [console] Update cat api * [console] autocomplete cat.tasks * Revert autocompletion * cat.aliases * generate cat * glob spec folder * [console] generate count * [console] remove leading slash from patterns * [console] generate bulk * [console] generate clear_scroll
This commit is contained in:
parent
d43677c451
commit
50d2f47c32
28 changed files with 585 additions and 81 deletions
|
@ -1,11 +1,10 @@
|
|||
let _ = require("lodash");
|
||||
let Api = require('./api');
|
||||
import { getSpec } from './spec'
|
||||
let parts = [
|
||||
require('./es_5_0/aliases'),
|
||||
require('./es_5_0/aggregations'),
|
||||
require('./es_5_0/cat'),
|
||||
require('./es_5_0/cluster'),
|
||||
require('./es_5_0/count'),
|
||||
require('./es_5_0/document'),
|
||||
require('./es_5_0/field_stats'),
|
||||
require('./es_5_0/filter'),
|
||||
|
@ -28,6 +27,11 @@ function ES_5_0() {
|
|||
_.each(parts, function (apiSection) {
|
||||
apiSection(this);
|
||||
}, this);
|
||||
|
||||
const spec = getSpec()
|
||||
Object.keys(spec).forEach(endpoint => {
|
||||
this.addEndpointDescription(endpoint, spec[endpoint])
|
||||
})
|
||||
}
|
||||
|
||||
ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 });
|
||||
|
@ -55,4 +59,4 @@ ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 });
|
|||
|
||||
const instance = new ES_5_0();
|
||||
|
||||
export default instance;
|
||||
export default instance;
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
let _ = require("lodash");
|
||||
|
||||
function addSimpleCat(endpoint, api, params, patterns) {
|
||||
var url_params = { "help": "__flag__", "v": "__flag__", "bytes": ["b"] };
|
||||
_.each(params || [], function (p) {
|
||||
if (_.isString(p)) {
|
||||
url_params[p] = "__flag__";
|
||||
}
|
||||
else {
|
||||
var k = Object.keys(p)[0];
|
||||
url_params[k] = p[k];
|
||||
}
|
||||
});
|
||||
api.addEndpointDescription(endpoint, {
|
||||
match: endpoint,
|
||||
url_params: url_params,
|
||||
patterns: patterns || [endpoint]
|
||||
});
|
||||
}
|
||||
|
||||
function addNodeattrsCat(api) {
|
||||
api.addEndpointDescription('_cat/nodeattrs', {
|
||||
methods: ['GET'],
|
||||
patterns: [
|
||||
"_cat/nodeattrs"
|
||||
],
|
||||
url_params: {
|
||||
help: "__flag__",
|
||||
v: "__flag__",
|
||||
h: ["node", "name", "id", "nodeId", "pid", "p", "host", "h", "ip", "i", "port", "po", "attr", "attr.name", "value", "attr.value"]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default function (api) {
|
||||
addSimpleCat('_cat/aliases', api);
|
||||
addSimpleCat('_cat/allocation', api, null, ['_cat/allocation', '_cat/allocation/{nodes}']);
|
||||
addSimpleCat('_cat/count', api);
|
||||
addSimpleCat('_cat/health', api, [
|
||||
{ "ts": ["false", "true"] }
|
||||
]);
|
||||
addSimpleCat('_cat/indices', api, [
|
||||
{ h: [] },
|
||||
"pri",
|
||||
],
|
||||
['_cat/indices', '_cat/indices/{indices}']);
|
||||
addSimpleCat('_cat/master', api);
|
||||
addSimpleCat('_cat/nodes', api);
|
||||
addSimpleCat('_cat/pending_tasks', api);
|
||||
addSimpleCat('_cat/recovery', api);
|
||||
addSimpleCat('_cat/thread_pool', api);
|
||||
addSimpleCat('_cat/shards', api);
|
||||
addSimpleCat('_cat/plugins', api);
|
||||
addSimpleCat('_cat/segments', api);
|
||||
addNodeattrsCat(api);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
export default function (api) {
|
||||
api.addEndpointDescription('_count', {
|
||||
methods: ['GET', 'POST'],
|
||||
priority: 10, // collides with get doc by id
|
||||
patterns: [
|
||||
"{indices}/{types}/_count",
|
||||
"{indices}/_count",
|
||||
"_count"
|
||||
],
|
||||
url_params: {
|
||||
preference: ["_primary", "_primary_first", "_local", "_only_node:xyz", "_prefer_node:xyz", "_shards:2,3"],
|
||||
routing: "",
|
||||
min_score: 1.0,
|
||||
terminate_after: 10,
|
||||
},
|
||||
data_autocomplete_rules: {
|
||||
query: {
|
||||
// populated by a global rule
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
29
src/core_plugins/console/api_server/spec/generated/bulk.json
Normal file
29
src/core_plugins/console/api_server/spec/generated/bulk.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"_bulk": {
|
||||
"url_params": {
|
||||
"wait_for_active_shards": "",
|
||||
"refresh": [
|
||||
"true",
|
||||
"false",
|
||||
"wait_for"
|
||||
],
|
||||
"routing": "",
|
||||
"timeout": "",
|
||||
"type": "",
|
||||
"fields": [],
|
||||
"_source": [],
|
||||
"_source_exclude": [],
|
||||
"_source_include": [],
|
||||
"pipeline": ""
|
||||
},
|
||||
"methods": [
|
||||
"POST",
|
||||
"PUT"
|
||||
],
|
||||
"patterns": [
|
||||
"_bulk",
|
||||
"{indices}/_bulk",
|
||||
"{indices}/{type}/_bulk"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/aliases": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/aliases",
|
||||
"_cat/aliases/{name}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"_cat/allocation": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"kb",
|
||||
"m",
|
||||
"mb",
|
||||
"g",
|
||||
"gb",
|
||||
"t",
|
||||
"tb",
|
||||
"p",
|
||||
"pb"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/allocation",
|
||||
"_cat/allocation/{nodes}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/count": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/count",
|
||||
"_cat/count/{indices}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"_cat/fielddata": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"kb",
|
||||
"m",
|
||||
"mb",
|
||||
"g",
|
||||
"gb",
|
||||
"t",
|
||||
"tb",
|
||||
"p",
|
||||
"pb"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__",
|
||||
"fields": []
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/fielddata",
|
||||
"_cat/fielddata/{fields}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/health": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"ts": "__flag__",
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/health"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"_cat": {
|
||||
"url_params": {
|
||||
"help": "__flag__",
|
||||
"s": []
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"_cat/indices": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"m",
|
||||
"g"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"health": [
|
||||
"green",
|
||||
"yellow",
|
||||
"red"
|
||||
],
|
||||
"help": "__flag__",
|
||||
"pri": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/indices",
|
||||
"_cat/indices/{indices}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"_cat/master": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/master"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"_cat/nodeattrs": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/nodeattrs"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/nodes": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"full_id": "__flag__",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/nodes"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"_cat/pending_tasks": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/pending_tasks"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"_cat/plugins": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/plugins"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"_cat/recovery": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"kb",
|
||||
"m",
|
||||
"mb",
|
||||
"g",
|
||||
"gb",
|
||||
"t",
|
||||
"tb",
|
||||
"p",
|
||||
"pb"
|
||||
],
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/recovery",
|
||||
"_cat/recovery/{indices}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"_cat/repositories": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/repositories"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"_cat/segments": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"kb",
|
||||
"m",
|
||||
"mb",
|
||||
"g",
|
||||
"gb",
|
||||
"t",
|
||||
"tb",
|
||||
"p",
|
||||
"pb"
|
||||
],
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/segments",
|
||||
"_cat/segments/{indices}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"_cat/shards": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"bytes": [
|
||||
"b",
|
||||
"k",
|
||||
"kb",
|
||||
"m",
|
||||
"mb",
|
||||
"g",
|
||||
"gb",
|
||||
"t",
|
||||
"tb",
|
||||
"p",
|
||||
"pb"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/shards",
|
||||
"_cat/shards/{indices}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/snapshots": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"ignore_unavailable": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/snapshots",
|
||||
"_cat/snapshots/{repository}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"_cat/tasks": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"node_id": [],
|
||||
"actions": [],
|
||||
"detailed": "__flag__",
|
||||
"parent_node": "",
|
||||
"parent_task": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/tasks"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"_cat/templates": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/templates",
|
||||
"_cat/templates/{name}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"_cat/thread_pool": {
|
||||
"url_params": {
|
||||
"format": "",
|
||||
"size": [
|
||||
"",
|
||||
"k",
|
||||
"m",
|
||||
"g",
|
||||
"t",
|
||||
"p"
|
||||
],
|
||||
"local": "__flag__",
|
||||
"master_timeout": "",
|
||||
"h": [],
|
||||
"help": "__flag__",
|
||||
"s": [],
|
||||
"v": "__flag__"
|
||||
},
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_cat/thread_pool",
|
||||
"_cat/thread_pool/{thread_pool_patterns}"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"_search/scroll/{scroll_id}": {
|
||||
"url_params": {},
|
||||
"methods": [
|
||||
"DELETE"
|
||||
],
|
||||
"patterns": [
|
||||
"_search/scroll/{scroll_id}",
|
||||
"_search/scroll"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"_count": {
|
||||
"url_params": {
|
||||
"ignore_unavailable": "__flag__",
|
||||
"allow_no_indices": "__flag__",
|
||||
"expand_wildcards": [
|
||||
"open",
|
||||
"closed",
|
||||
"none",
|
||||
"all"
|
||||
],
|
||||
"min_score": "",
|
||||
"preference": "random",
|
||||
"routing": [],
|
||||
"q": "",
|
||||
"analyzer": "",
|
||||
"analyze_wildcard": "__flag__",
|
||||
"default_operator": [
|
||||
"AND",
|
||||
"OR"
|
||||
],
|
||||
"df": "",
|
||||
"lenient": "__flag__",
|
||||
"terminate_after": ""
|
||||
},
|
||||
"methods": [
|
||||
"POST",
|
||||
"GET"
|
||||
],
|
||||
"patterns": [
|
||||
"_count",
|
||||
"{indices}/_count",
|
||||
"{indices}/{type}/_count"
|
||||
]
|
||||
}
|
||||
}
|
19
src/core_plugins/console/api_server/spec/index.js
Normal file
19
src/core_plugins/console/api_server/spec/index.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const glob = require('glob')
|
||||
const { join, basename } = require('path')
|
||||
const { readFileSync } = require('fs')
|
||||
const { merge } = require('lodash')
|
||||
|
||||
export function getSpec() {
|
||||
const generatedFiles = glob.sync(join(__dirname, 'generated', '*.json'))
|
||||
const overrideFiles = glob.sync(join(__dirname, 'overrides', '*.json'))
|
||||
|
||||
return generatedFiles.reduce((acc, file) => {
|
||||
const overrideFile = overrideFiles.find(f => basename(f) === basename(file))
|
||||
const spec = JSON.parse(readFileSync(file, 'utf8'))
|
||||
if (overrideFile) {
|
||||
merge(spec, JSON.parse(readFileSync(overrideFile, 'utf8')))
|
||||
}
|
||||
return { ...acc, ...spec };
|
||||
}, {});
|
||||
return result
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"_count": {
|
||||
"priority": 10,
|
||||
"data_autocomplete_rules": {
|
||||
"query": {}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue