Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/core_plugins/console/api_server/spec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { readFileSync } from 'fs';
import { merge } from 'lodash';

const extensionSpecFilePaths = [];
export function getSpec() {
const generatedFiles = glob.sync(join(__dirname, 'generated', '*.json'));
const overrideFiles = glob.sync(join(__dirname, 'overrides', '*.json'));
function _getSpec(dirname = __dirname) {
const generatedFiles = glob.sync(join(dirname, 'generated', '*.json'));
const overrideFiles = glob.sync(join(dirname, 'overrides', '*.json'));

const result = generatedFiles.reduce((acc, file) => {
return generatedFiles.reduce((acc, file) => {
const overrideFile = overrideFiles.find(f => basename(f) === basename(file));
const loadedSpec = JSON.parse(readFileSync(file, 'utf8'));
if (overrideFile) {
Expand All @@ -45,11 +45,11 @@ export function getSpec() {

return { ...acc, ...spec };
}, {});
}
export function getSpec() {
const result = _getSpec();
extensionSpecFilePaths.forEach((extensionSpecFilePath) => {
const extensionFiles = glob.sync(join(extensionSpecFilePath, '*.json'));
extensionFiles.forEach((extensionFile) => {
merge(result, JSON.parse(readFileSync(extensionFile, 'utf8')));
});
merge(result, _getSpec(extensionSpecFilePath));
});
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function compileDescription(description, compilingContext) {

function compileParametrizedValue(value, compilingContext, template) {
value = value.substr(1, value.length - 2).toLowerCase();
let component = compilingContext.parametrizedComponentFactories[value];
let component = compilingContext.parametrizedComponentFactories.getComponent(value, true);
if (!component) {
throw new Error('no factory found for \'' + value + '\'');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export class UrlPatternMatcher {
['HEAD', 'GET', 'PUT', 'POST', 'DELETE'].forEach((method) => {
this[method] = {
rootComponent: new SharedComponent('ROOT'),
parametrizedComponentFactories: parametrizedComponentFactories || {}
parametrizedComponentFactories: parametrizedComponentFactories || {
getComponent: () => {}
}
};
});
}
Expand Down Expand Up @@ -87,7 +89,7 @@ export class UrlPatternMatcher {
);
c = new SharedComponent(part);
}
} else if ((c = this[method].parametrizedComponentFactories[part])) {
} else if ((c = this[method].parametrizedComponentFactories.getComponent(part))) {
// c is a f
c = c(part, activeComponent);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ module.controller('SenseController', function SenseController(Private, $scope, $
const position = requests[0].range.end;
position.column = position.column - 1;
const endpoint = getEndpointFromPosition(input, position);
if (endpoint && endpoint.documentation) {
if (endpoint
&& endpoint.documentation
&& endpoint.documentation.indexOf('http') !== -1) {
$scope.documentation = endpoint.documentation.replace('master', DOC_LINK_VERSION);
$scope.$apply();
} else {
Expand Down
16 changes: 13 additions & 3 deletions src/core_plugins/console/public/src/kb.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ import Api from './kb/api';
let ACTIVE_API = new Api();
const isNotAnIndexName = name => name[0] === '_' && name !== '_all';

const idAutocompleteComponentFactory = (name, parent) => {
return new IdAutocompleteComponent(name, parent);
};
const parametrizedComponentFactories = {
getComponent: function (name, parent, provideDefault) {
if (this[name]) {
return this[name];
} else if (provideDefault) {
return idAutocompleteComponentFactory;
}
},
index: function (name, parent) {
if (isNotAnIndexName(name)) return;
return new IndexAutocompleteComponent(name, parent, false);
Expand All @@ -48,13 +58,13 @@ const parametrizedComponentFactories = {
return new TypeAutocompleteComponent(name, parent, true);
},
id: function (name, parent) {
return new IdAutocompleteComponent(name, parent);
return idAutocompleteComponentFactory(name, parent);
},
task_id: function (name, parent) {
return new IdAutocompleteComponent(name, parent);
return idAutocompleteComponentFactory(name, parent);
},
ids: function (name, parent) {
return new IdAutocompleteComponent(name, parent, true);
return idAutocompleteComponentFactory(name, parent, true);
},
fields: function (name, parent) {
return new FieldAutocompleteComponent(name, parent, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ describe('Url autocomplete', () => {
p: function (name, parent) {
return new ListComponent(name, ['g1', 'g2'], parent);
},
getComponent(name) {
return this[name];
}
};

patternsTest(
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/console_extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function consoleExtensions(kibana) {
server.plugins.console.addExtensionSpecFilePath
) {
server.plugins.console.addExtensionSpecFilePath(
join(__dirname, 'spec')
join(__dirname, 'spec/')
);
} else {
console.warn(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"xpack.graph.explore": {
"url_params": {
"routing": "",
"timeout": ""
},
"methods": [
"GET",
"POST"
],
"patterns": [
"{indices}/_xpack/graph/_explore",
"{indices}/{type}/_xpack/graph/_explore"
],
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html"
}
}
14 changes: 14 additions & 0 deletions x-pack/plugins/console_extensions/spec/generated/xpack.info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"xpack.info": {
"url_params": {
"categories": []
},
"methods": [
"GET"
],
"patterns": [
"_xpack"
],
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"xpack.license.delete": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/license"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"xpack.license.get": {
"url_params": {
"local": "__flag__"
},
"methods": [
"GET"
],
"patterns": [
"_xpack/license"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"xpack.license.get_basic_status": {
"methods": [
"GET"
],
"patterns": [
"_xpack/license/basic_status"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"xpack.license.get_trial_status": {
"methods": [
"GET"
],
"patterns": [
"_xpack/license/trial_status"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"xpack.license.post": {
"url_params": {
"acknowledge": "__flag__"
},
"methods": [
"PUT",
"POST"
],
"patterns": [
"_xpack/license"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"xpack.license.post_start_basic": {
"url_params": {
"acknowledge": "__flag__"
},
"methods": [
"POST"
],
"patterns": [
"_xpack/license/start_basic"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"xpack.license.post_start_trial": {
"url_params": {
"type": "\"trial\"",
"acknowledge": "__flag__"
},
"methods": [
"POST"
],
"patterns": [
"_xpack/license/start_trial"
],
"documentation": "https://www.elastic.co/guide/en/x-pack/current/license-management.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"xpack.migration.deprecations": {
"methods": [
"GET"
],
"patterns": [
"_xpack/migration/deprecations",
"{indices}/_xpack/migration/deprecations"
],
"documentation": "http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"xpack.migration.get_assistance": {
"url_params": {
"allow_no_indices": "__flag__",
"expand_wildcards": [
"open",
"closed",
"none",
"all"
],
"ignore_unavailable": "__flag__"
},
"methods": [
"GET"
],
"patterns": [
"_xpack/migration/assistance",
"_xpack/migration/assistance/{indices}"
],
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-assistance.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"xpack.migration.upgrade": {
"url_params": {
"wait_for_completion": "__flag__"
},
"methods": [
"POST"
],
"patterns": [
"_xpack/migration/upgrade/{indices}"
],
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"xpack.ml.close_job": {
"url_params": {
"allow_no_jobs": "__flag__",
"force": "__flag__",
"timeout": ""
},
"methods": [
"POST"
],
"patterns": [
"_xpack/ml/anomaly_detectors/{job_id}/_close"
],
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"xpack.ml.delete_calendar": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/calendars/{calendar_id}"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"xpack.ml.delete_calendar_event": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/calendars/{calendar_id}/events/{event_id}"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"xpack.ml.delete_calendar_job": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/calendars/{calendar_id}/jobs/{job_id}"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"xpack.ml.delete_datafeed": {
"url_params": {
"force": "__flag__"
},
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/datafeeds/{datafeed_id}"
],
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"xpack.ml.delete_expired_data": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/_delete_expired_data"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"xpack.ml.delete_filter": {
"methods": [
"DELETE"
],
"patterns": [
"_xpack/ml/filters/{filter_id}"
]
}
}
Loading