public class RestActions
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & ToXContent>
NodesResponseRestBuilderListener automatically translates any BaseNodesResponse (multi-node) response that is
ToXContent -compatible into a RestResponse with the necessary header info (e.g., "cluster_name"). |
Constructor and Description |
---|
RestActions() |
Modifier and Type | Method and Description |
---|---|
static void |
buildBroadcastShardsHeader(XContentBuilder builder,
ToXContent.Params params,
BroadcastResponse response) |
static void |
buildBroadcastShardsHeader(XContentBuilder builder,
ToXContent.Params params,
int total,
int successful,
int failed,
ShardOperationFailedException[] shardFailures) |
static <NodeResponse extends BaseNodeResponse> |
buildNodesHeader(XContentBuilder builder,
ToXContent.Params params,
BaseNodesResponse<NodeResponse> response)
Create the XContent header for any
BaseNodesResponse . |
static void |
buildNodesHeader(XContentBuilder builder,
ToXContent.Params params,
int total,
int successful,
int failed,
java.util.List<FailedNodeException> failures)
Create the XContent header for any
BaseNodesResponse . |
static QueryBuilder |
getQueryContent(BytesReference source,
IndicesQueriesRegistry indicesQueriesRegistry,
ParseFieldMatcher parseFieldMatcher) |
static BytesReference |
getRestContent(RestRequest request)
Get Rest content from either payload or source parameter
|
static XContentType |
guessBodyContentType(RestRequest request)
guesses the content type from either payload or source parameter
|
static boolean |
hasBodyContent(RestRequest request)
Returns
true if either payload or source parameter is present. |
static <NodesResponse extends BaseNodesResponse & ToXContent> |
nodesResponse(XContentBuilder builder,
ToXContent.Params params,
NodesResponse response)
|
static long |
parseVersion(RestRequest request) |
static long |
parseVersion(RestRequest request,
long defaultVersion) |
static QueryBuilder |
urlParamsToQueryBuilder(RestRequest request) |
public static long parseVersion(RestRequest request)
public static long parseVersion(RestRequest request, long defaultVersion)
public static void buildBroadcastShardsHeader(XContentBuilder builder, ToXContent.Params params, BroadcastResponse response) throws java.io.IOException
java.io.IOException
public static void buildBroadcastShardsHeader(XContentBuilder builder, ToXContent.Params params, int total, int successful, int failed, ShardOperationFailedException[] shardFailures) throws java.io.IOException
java.io.IOException
public static <NodeResponse extends BaseNodeResponse> void buildNodesHeader(XContentBuilder builder, ToXContent.Params params, BaseNodesResponse<NodeResponse> response) throws java.io.IOException
BaseNodesResponse
.builder
- XContent builder.params
- XContent parameters.response
- The response containing individual, node-level responses.java.io.IOException
#buildNodesHeader(XContentBuilder, Params, int, int, int, List)
public static void buildNodesHeader(XContentBuilder builder, ToXContent.Params params, int total, int successful, int failed, java.util.List<FailedNodeException> failures) throws java.io.IOException
BaseNodesResponse
. This looks like:
"_nodes" : {
"total" : 3,
"successful" : 1,
"failed" : 2,
"failures" : [ { ... }, { ... } ]
}
Prefer the overload that properly invokes this method to calling this directly.builder
- XContent builder.params
- XContent parameters.total
- The total number of nodes touched.successful
- The successful number of responses received.failed
- The number of failures (effectively total - successful
).failures
- The failure exceptions related to failed
.java.io.IOException
#buildNodesHeader(XContentBuilder, Params, BaseNodesResponse)
public static <NodesResponse extends BaseNodesResponse & ToXContent> BytesRestResponse nodesResponse(XContentBuilder builder, ToXContent.Params params, NodesResponse response) throws java.io.IOException
ToXContent
-compatible, nodes-level response
into a a BytesRestResponse
.
This looks like:
{
"_nodes" : { ... },
"cluster_name" : "...",
...
}
builder
- XContent builder.params
- XContent parameters.response
- The nodes-level (plural) response.null
.java.io.IOException
- if building the response causes an issuepublic static QueryBuilder urlParamsToQueryBuilder(RestRequest request)
public static BytesReference getRestContent(RestRequest request)
request
- Rest requestpublic static QueryBuilder getQueryContent(BytesReference source, IndicesQueriesRegistry indicesQueriesRegistry, ParseFieldMatcher parseFieldMatcher)
public static XContentType guessBodyContentType(RestRequest request)
request
- Rest requestnull
if not applicable.public static boolean hasBodyContent(RestRequest request)
true
if either payload or source parameter is present. Otherwise false