Changed the default output of X-Pack Info API

- by default the response includes all info - build, license, features + human descriptions.
- you can still control the output using `categories` and `human` parameters
- Added docs to this API

Original commit: elastic/x-pack-elasticsearch@85115495ec
This commit is contained in:
uboness 2016-04-21 09:50:44 -07:00
parent c012b397f4
commit df3bbd42b9
3 changed files with 71 additions and 53 deletions

View File

@ -25,8 +25,15 @@ public class XPackInfoRequest extends ActionRequest<XPackInfoRequest> {
public static EnumSet<Category> toSet(String... categories) { public static EnumSet<Category> toSet(String... categories) {
EnumSet<Category> set = EnumSet.noneOf(Category.class); EnumSet<Category> set = EnumSet.noneOf(Category.class);
for (String category : categories) { for (String category : categories) {
switch (category) {
case "_all":
return EnumSet.allOf(Category.class);
case "_none":
return EnumSet.noneOf(Category.class);
default:
set.add(Category.valueOf(category.toUpperCase(Locale.ROOT))); set.add(Category.valueOf(category.toUpperCase(Locale.ROOT)));
} }
}
return set; return set;
} }
} }

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.rest.action; package org.elasticsearch.xpack.rest.action;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -40,10 +39,10 @@ public class RestXPackInfoAction extends XPackRestHandler {
protected void handleRequest(RestRequest request, RestChannel restChannel, XPackClient client) throws Exception { protected void handleRequest(RestRequest request, RestChannel restChannel, XPackClient client) throws Exception {
// we piggyback verbosity on "human" output // we piggyback verbosity on "human" output
boolean verbose = request.paramAsBoolean("human", false); boolean verbose = request.paramAsBoolean("human", true);
EnumSet<XPackInfoRequest.Category> categories = XPackInfoRequest.Category EnumSet<XPackInfoRequest.Category> categories = XPackInfoRequest.Category
.toSet(request.paramAsStringArray("categories", Strings.EMPTY_ARRAY)); .toSet(request.paramAsStringArray("categories", new String[] { "_all" }));
client.prepareInfo().setVerbose(verbose).setCategories(categories).execute(new RestBuilderListener<XPackInfoResponse>(restChannel) { client.prepareInfo().setVerbose(verbose).setCategories(categories).execute(new RestBuilderListener<XPackInfoResponse>(restChannel) {
@Override @Override
public RestResponse buildResponse(XPackInfoResponse infoResponse, XContentBuilder builder) throws Exception { public RestResponse buildResponse(XPackInfoResponse infoResponse, XContentBuilder builder) throws Exception {

View File

@ -56,24 +56,6 @@
- do: - do:
xpack.info: {} xpack.info: {}
- is_false: tagline
- is_false: build
- is_false: features
- is_false: license
- do:
xpack.info:
categories: "build"
- is_true: build
- is_true: build.hash
- is_true: build.timestamp
- is_false: tagline
- is_false: features
- is_false: license
- do:
xpack.info:
categories: "build,license"
- is_true: build.hash - is_true: build.hash
- is_true: build.timestamp - is_true: build.timestamp
- is_true: license - is_true: license
@ -82,12 +64,71 @@
- match: { license.mode: "platinum" } - match: { license.mode: "platinum" }
- match: { license.status: "active" } - match: { license.status: "active" }
- match: { license.expiry_date_in_millis: 1914278399999 } - match: { license.expiry_date_in_millis: 1914278399999 }
- is_false: tagline - is_true: features
- is_true: features.watcher
- is_true: features.watcher.enabled
- is_true: features.watcher.available
- is_true: features.watcher.description
- is_true: features.security
- is_true: features.security.enabled
- is_true: features.security.available
- is_true: features.security.description
- is_true: features.graph
- is_true: features.graph.enabled
- is_true: features.graph.available
- is_true: features.graph.description
- is_true: features.monitoring
- is_true: features.monitoring.enabled
- is_true: features.monitoring.available
- is_true: features.monitoring.description
- is_true: tagline
- do:
xpack.info:
categories: "_none"
- is_false: build
- is_false: features - is_false: features
- is_false: license
- match: { tagline: "You know, for X" }
- do:
xpack.info:
categories: "_none"
human: false
- is_false: build
- is_false: features
- is_false: license
- is_false: tagline
- do:
xpack.info:
categories: "build"
- is_true: build
- is_true: build.hash
- is_true: build.timestamp
- is_true: tagline
- is_false: features
- is_false: license
- do:
xpack.info:
categories: "build,license"
- is_true: build.hash
- is_true: build.timestamp
- is_true: tagline
- is_false: features
- is_true: license
- match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" }
- match: { license.type: "internal" }
- match: { license.mode: "platinum" }
- match: { license.status: "active" }
- match: { license.expiry_date_in_millis: 1914278399999 }
- do: - do:
xpack.info: xpack.info:
categories: "build,license,features" categories: "build,license,features"
human: false
- is_true: build.hash - is_true: build.hash
- is_true: build.timestamp - is_true: build.timestamp
- is_true: license - is_true: license
@ -115,33 +156,4 @@
- is_false: features.monitoring.description - is_false: features.monitoring.description
- is_false: tagline - is_false: tagline
- do:
xpack.info:
categories: "build,license,features"
human: "true"
- is_true: build.hash
- is_true: build.timestamp
- is_true: license
- match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" }
- match: { license.type: "internal" }
- match: { license.mode: "platinum" }
- match: { license.status: "active" }
- match: { license.expiry_date_in_millis: 1914278399999 }
- is_true: features
- is_true: features.watcher
- is_true: features.watcher.enabled
- is_true: features.watcher.available
- is_true: features.watcher.description
- is_true: features.security
- is_true: features.security.enabled
- is_true: features.security.available
- is_true: features.security.description
- is_true: features.graph
- is_true: features.graph.enabled
- is_true: features.graph.available
- is_true: features.graph.description
- is_true: features.monitoring
- is_true: features.monitoring.enabled
- is_true: features.monitoring.available
- is_true: features.monitoring.description
- is_true: tagline