Remove hard-coded "ok": true from REST responses

This commit is contained in:
Lee Hinman 2013-12-04 12:16:58 -07:00
parent 7166ab6b6f
commit d23f640cd1
41 changed files with 5 additions and 81 deletions

View File

@ -2,7 +2,6 @@
"node_info test":
- do:
cluster.node_info: {}
- is_true: ok
- is_true: nodes
- is_true: cluster_name

View File

@ -2,5 +2,3 @@
"Basic sanity check":
- do:
cluster.reroute: {}
- is_true: ok

View File

@ -7,7 +7,6 @@
id: 1
body: { foo: bar }
- is_true: ok
- match: { _index: test_1 }
- match: { _type: test }
- match: { _id: "1"}

View File

@ -6,7 +6,6 @@
type: test
body: { foo: bar }
- is_true: ok
- is_true: _id
- match: { _index: test_1 }
- match: { _type: test }
@ -24,4 +23,3 @@
- match: { _id: $id }
- match: { _version: 1 }
- match: { _source: { foo: bar }}

View File

@ -8,7 +8,6 @@
id: 1
body: { foo: bar }
- is_true: ok
- match: { _version: 1 }
- do:

View File

@ -32,8 +32,6 @@
match:
foo: bar
- is_true: ok
- do:
indices.refresh: {}

View File

@ -20,6 +20,4 @@
match_all: {}
- is_true: matched
- is_true: ok
- match: { explanation.value: 1 }

View File

@ -8,7 +8,6 @@
id: 1
body: { foo: bar }
- is_true: ok
- match: { _index: test-weird-index-中文 }
- match: { _type: weird.type }
- match: { _id: "1"}
@ -25,4 +24,3 @@
- match: { _id: "1"}
- match: { _version: 1}
- match: { _source: { foo: bar }}

View File

@ -7,7 +7,6 @@
type: test
body: { foo: bar }
- is_true: ok
- is_true: _id
- match: { _index: test_1 }
- match: { _type: test }
@ -25,4 +24,3 @@
- match: { _id: $id }
- match: { _version: 1 }
- match: { _source: { foo: bar }}

View File

@ -2,5 +2,3 @@
"clear_cache test":
- do:
indices.clear_cache: {}
- is_true: ok

View File

@ -8,5 +8,3 @@
indices.optimize:
index: testing
max_num_segments: 1
- is_true: ok

View File

@ -16,8 +16,6 @@
index: test_index
name: test_alias
- is_true: ok
- do:
indices.exists_alias:
name: test_alias

View File

@ -9,8 +9,6 @@
number_of_shards: 1
number_of_replicas: 0
- is_true: ok
- do:
indices.get_template:
name: test

View File

@ -7,7 +7,7 @@
- do:
cluster.health:
wait_for_status: yellow
- do:
catch: missing
indices.get_warmer:
@ -22,8 +22,6 @@
query:
match_all: {}
- is_true: ok
- do:
indices.get_warmer:
index: test_index
@ -35,8 +33,6 @@
indices.delete_warmer:
index: test_index
- is_true: ok
- do:
catch: missing
indices.get_warmer:

View File

@ -3,5 +3,3 @@
- do:
indices.segments:
allow_no_indices: true
- is_true: ok

View File

@ -2,5 +2,3 @@
"snapshot_index test":
- do:
indices.snapshot_index: {}
- is_true: ok

View File

@ -2,5 +2,3 @@
"stats test":
- do:
indices.stats: {}
- is_true: ok

View File

@ -3,10 +3,7 @@
- do:
indices.status: {}
- is_true: ok
- do:
catch: missing
indices.status:
index: not_here

View File

@ -20,8 +20,6 @@
alias: test_alias
routing: routing_value
- is_true: ok
- do:
indices.exists_alias:
name: test_alias
@ -34,4 +32,3 @@
name: test_alias
- match: {test_index.aliases.test_alias: {'index_routing': 'routing_value', 'search_routing': 'routing_value'}}

View File

@ -2,10 +2,7 @@
"Info":
- do: {info: {}}
- match: {status: 200}
- is_true: ok
- is_true: name
- is_true: tagline
- is_true: version
- is_true: version.number

View File

@ -41,7 +41,6 @@ public class AcknowledgedRestResponseActionListener<T extends AcknowledgedRespon
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged());
addCustomFields(builder, response);
builder.endObject();
@ -60,7 +59,6 @@ public class AcknowledgedRestResponseActionListener<T extends AcknowledgedRespon
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString ACKNOWLEDGED = new XContentBuilderString("acknowledged");
}
}

View File

@ -116,7 +116,6 @@ public class RestNodesInfoAction extends BaseRestHandler {
response.settingsFilter(settingsFilter);
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
response.toXContent(builder, request);
builder.endObject();
channel.sendResponse(new XContentRestResponse(request, RestStatus.OK, builder));

View File

@ -70,7 +70,6 @@ public class RestClusterSearchShardsAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
response.toXContent(builder, request);
builder.endObject();
channel.sendResponse(new XContentRestResponse(request, RestStatus.OK, builder));

View File

@ -106,7 +106,6 @@ public class RestClearIndicesCacheAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);

View File

@ -73,7 +73,6 @@ public class RestFlushAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);

View File

@ -61,7 +61,6 @@ public class RestGatewaySnapshotAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);

View File

@ -87,7 +87,6 @@ public class RestOptimizeAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);

View File

@ -72,7 +72,6 @@ public class RestRefreshAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);

View File

@ -66,7 +66,6 @@ public class RestIndicesSegmentsAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);
response.toXContent(builder, request);
builder.endObject();

View File

@ -105,7 +105,6 @@ public class RestIndicesStatsAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);
response.toXContent(builder, request);
builder.endObject();

View File

@ -75,7 +75,6 @@ public class RestIndicesStatusAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();
builder.field("ok", true);
buildBroadcastShardsHeader(builder, response);
response.toXContent(builder, request, settingsFilter);
builder.endObject();

View File

@ -125,7 +125,6 @@ public class RestBulkAction extends BaseRestHandler {
builder.field(Fields.STATUS, itemResponse.getFailure().getStatus().getStatus());
builder.field(Fields.ERROR, itemResponse.getFailure().getMessage());
} else {
builder.field(Fields.OK, true);
if (itemResponse.getResponse() instanceof DeleteResponse) {
DeleteResponse deleteResponse = itemResponse.getResponse();
if (deleteResponse.isNotFound()) {
@ -181,7 +180,6 @@ public class RestBulkAction extends BaseRestHandler {
static final XContentBuilderString _ID = new XContentBuilderString("_id");
static final XContentBuilderString STATUS = new XContentBuilderString("status");
static final XContentBuilderString ERROR = new XContentBuilderString("error");
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString TOOK = new XContentBuilderString("took");
static final XContentBuilderString _VERSION = new XContentBuilderString("_version");
static final XContentBuilderString FOUND = new XContentBuilderString("found");

View File

@ -80,7 +80,6 @@ public class RestDeleteAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field(Fields.OK, true)
.field(Fields.FOUND, !result.isNotFound())
.field(Fields._INDEX, result.getIndex())
.field(Fields._TYPE, result.getType())
@ -109,7 +108,6 @@ public class RestDeleteAction extends BaseRestHandler {
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString FOUND = new XContentBuilderString("found");
static final XContentBuilderString _INDEX = new XContentBuilderString("_index");
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");

View File

@ -100,8 +100,7 @@ public class RestDeleteByQueryAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
RestStatus restStatus = result.status();
builder.startObject().field("ok", restStatus == RestStatus.OK);
builder.startObject();
builder.startObject("_indices");
for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : result.getIndices().values()) {
builder.startObject(indexDeleteByQueryResponse.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
@ -115,7 +114,6 @@ public class RestDeleteByQueryAction extends BaseRestHandler {
builder.endObject();
}
builder.endObject();
builder.endObject();
channel.sendResponse(new XContentRestResponse(request, restStatus, builder));
} catch (Throwable e) {

View File

@ -110,8 +110,7 @@ public class RestExplainAction extends BaseRestHandler {
try {
XContentBuilder builder = restContentBuilder(request);
builder.startObject();
builder.field(Fields.OK, response.isExists())
.field(Fields._INDEX, explainRequest.index())
builder.field(Fields._INDEX, explainRequest.index())
.field(Fields._TYPE, explainRequest.type())
.field(Fields._ID, explainRequest.id())
.field(Fields.MATCHED, response.isMatch());
@ -161,7 +160,6 @@ public class RestExplainAction extends BaseRestHandler {
}
static class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString _INDEX = new XContentBuilderString("_index");
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
static final XContentBuilderString _ID = new XContentBuilderString("_id");

View File

@ -109,7 +109,6 @@ public class RestIndexAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field(Fields.OK, true)
.field(Fields._INDEX, response.getIndex())
.field(Fields._TYPE, response.getType())
.field(Fields._ID, response.getId())
@ -137,7 +136,6 @@ public class RestIndexAction extends BaseRestHandler {
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString _INDEX = new XContentBuilderString("_index");
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
static final XContentBuilderString _ID = new XContentBuilderString("_id");

View File

@ -80,7 +80,6 @@ public class RestMainAction extends BaseRestHandler {
}
builder.startObject();
builder.field("ok", true);
builder.field("status", status.getStatus());
if (settings.get("name") != null) {
builder.field("name", settings.get("name"));

View File

@ -61,7 +61,6 @@ public class RestClearScrollAction extends BaseRestHandler {
try {
XContentBuilder builder = restContentBuilder(request);
builder.startObject();
builder.field(Fields.OK, response.isSucceeded());
builder.endObject();
channel.sendResponse(new XContentRestResponse(request, OK, builder));
} catch (Throwable e) {
@ -86,10 +85,4 @@ public class RestClearScrollAction extends BaseRestHandler {
}
return Strings.splitStringByCommaToArray(scrollIds);
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
}
}

View File

@ -131,7 +131,6 @@ public class RestUpdateAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field(Fields.OK, true)
.field(Fields._INDEX, response.getIndex())
.field(Fields._TYPE, response.getType())
.field(Fields._ID, response.getId())
@ -166,7 +165,6 @@ public class RestUpdateAction extends BaseRestHandler {
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString _INDEX = new XContentBuilderString("_index");
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
static final XContentBuilderString _ID = new XContentBuilderString("_id");

View File

@ -147,7 +147,6 @@ public class RiversService extends AbstractLifecycleComponent<RiversService> {
river.start();
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
builder.field("ok", true);
builder.startObject("node");
builder.field("id", clusterService.localNode().id());

View File

@ -262,13 +262,12 @@ public class TestSectionParserTests extends AbstractParserTests {
" - do:\n" +
" cluster.node_info: {}\n" +
" \n" +
" - is_true: ok\n" +
" - is_true: nodes\n" +
" - is_true: cluster_name\n");
RestTestSectionParser testSectionParser = new RestTestSectionParser();
TestSection testSection = testSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser, "0.90.5"));
assertThat(testSection, notNullValue());
assertThat(testSection.getName(), equalTo("node_info test"));
assertThat(testSection.getExecutableSections().size(), equalTo(4));
assertThat(testSection.getExecutableSections().size(), equalTo(3));
}
}