Package org.elasticsearch.rest
Class BaseRestHandler
java.lang.Object
org.elasticsearch.rest.BaseRestHandler
- All Implemented Interfaces:
RestHandler
- Direct Known Subclasses:
AbstractCatAction,BaseRestHandler.Wrapper,RestAddIndexBlockAction,RestAddVotingConfigExclusionAction,RestAnalyzeAction,RestBulkAction,RestCancelTasksAction,RestCatAction,RestCleanupRepositoryAction,RestClearIndicesCacheAction,RestClearScrollAction,RestClearVotingConfigExclusionsAction,RestCloneSnapshotAction,RestCloseIndexAction,RestClusterAllocationExplainAction,RestClusterGetSettingsAction,RestClusterHealthAction,RestClusterRerouteAction,RestClusterSearchShardsAction,RestClusterStateAction,RestClusterStatsAction,RestClusterUpdateSettingsAction,RestCountAction,RestCreateIndexAction,RestCreateSnapshotAction,RestDeleteAction,RestDeleteComponentTemplateAction,RestDeleteComposableIndexTemplateAction,RestDeleteDanglingIndexAction,RestDeleteIndexAction,RestDeleteIndexTemplateAction,RestDeletePipelineAction,RestDeleteRepositoryAction,RestDeleteSnapshotAction,RestDeleteStoredScriptAction,RestExplainAction,RestFieldCapabilitiesAction,RestFlushAction,RestForceMergeAction,RestGetAction,RestGetAliasesAction,RestGetComponentTemplateAction,RestGetComposableIndexTemplateAction,RestGetFieldMappingAction,RestGetIndexTemplateAction,RestGetIndicesAction,RestGetMappingAction,RestGetPipelineAction,RestGetRepositoriesAction,RestGetScriptContextAction,RestGetScriptLanguageAction,RestGetSettingsAction,RestGetSnapshotsAction,RestGetSourceAction,RestGetStoredScriptAction,RestGetTaskAction,RestImportDanglingIndexAction,RestIndexAction,RestIndexDeleteAliasesAction,RestIndexPutAliasAction,RestIndicesAliasesAction,RestIndicesSegmentsAction,RestIndicesShardStoresAction,RestIndicesStatsAction,RestListDanglingIndicesAction,RestListTasksAction,RestMainAction,RestMultiGetAction,RestMultiSearchAction,RestMultiTermVectorsAction,RestNodesHotThreadsAction,RestNodesInfoAction,RestNodesStatsAction,RestNodesUsageAction,RestOpenIndexAction,RestPendingClusterTasksAction,RestPutComponentTemplateAction,RestPutComposableIndexTemplateAction,RestPutIndexTemplateAction,RestPutMappingAction,RestPutPipelineAction,RestPutRepositoryAction,RestPutStoredScriptAction,RestRecoveryAction,RestRefreshAction,RestReloadSecureSettingsAction,RestRemoteClusterInfoAction,RestResizeHandler,RestResolveIndexAction,RestRestoreSnapshotAction,RestRolloverIndexAction,RestSearchAction,RestSearchScrollAction,RestSimulateIndexTemplateAction,RestSimulatePipelineAction,RestSimulateTemplateAction,RestSnapshotsStatusAction,RestSyncedFlushAction,RestTermVectorsAction,RestUpdateAction,RestUpdateSettingsAction,RestUpgradeAction,RestUpgradeStatusAction,RestValidateQueryAction,RestVerifyRepositoryAction
public abstract class BaseRestHandler extends java.lang.Object implements RestHandler
Base handler for REST requests.
This handler makes sure that the headers & context of the handled requests are copied over to
the transport requests executed by the associated client. While the context is fully copied over, not all the headers
are copied, but a selected few. It is possible to control what headers are copied over by returning them in
ActionPlugin.getRestHeaders().
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceBaseRestHandler.RestChannelConsumerREST requests are handled by preparing a channel consumer that represents the execution of the request against a channel.static classBaseRestHandler.WrapperNested classes/interfaces inherited from interface org.elasticsearch.rest.RestHandler
RestHandler.DeprecatedRoute, RestHandler.ReplacedRoute, RestHandler.Route -
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_INCLUDE_TYPE_NAME_POLICYstatic java.lang.StringINCLUDE_TYPE_NAME_PARAMETERParameter that controls whether certain REST apis should include type names in their requests or responses.protected org.apache.logging.log4j.LoggerloggerDeprecated.declare your own logger.static Setting<java.lang.Boolean>MULTI_ALLOW_EXPLICIT_INDEX -
Constructor Summary
Constructors Constructor Description BaseRestHandler() -
Method Summary
Modifier and Type Method Description abstract java.lang.StringgetName()longgetUsageCount()voidhandleRequest(RestRequest request, RestChannel channel, NodeClient client)Handles a rest request.protected abstract BaseRestHandler.RestChannelConsumerprepareRequest(RestRequest request, NodeClient client)Prepare the request for execution.protected java.util.Set<java.lang.String>responseParams()Parameters used for controlling the response and thus might not be consumed during preparation of the request execution inprepareRequest(RestRequest, NodeClient).abstract java.util.List<RestHandler.Route>routes()The list ofRestHandler.Routes that this RestHandler is responsible for handling.protected java.lang.Stringunrecognized(RestRequest request, java.util.Set<java.lang.String> invalids, java.util.Set<java.lang.String> candidates, java.lang.String detail)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.rest.RestHandler
allowsUnsafeBuffers, allowSystemIndexAccessByDefault, canTripCircuitBreaker, deprecatedRoutes, replacedRoutes, supportsContentStream
-
Field Details
-
MULTI_ALLOW_EXPLICIT_INDEX
-
logger
@Deprecated protected org.apache.logging.log4j.Logger loggerDeprecated.declare your own logger. -
INCLUDE_TYPE_NAME_PARAMETER
public static final java.lang.String INCLUDE_TYPE_NAME_PARAMETERParameter that controls whether certain REST apis should include type names in their requests or responses. Note: Support for this parameter will be removed after the transition period to typeless APIs.- See Also:
- Constant Field Values
-
DEFAULT_INCLUDE_TYPE_NAME_POLICY
public static final boolean DEFAULT_INCLUDE_TYPE_NAME_POLICY- See Also:
- Constant Field Values
-
-
Constructor Details
-
BaseRestHandler
public BaseRestHandler()
-
-
Method Details
-
getUsageCount
public final long getUsageCount() -
getName
public abstract java.lang.String getName()- Returns:
- the name of this handler. The name should be human readable and
should describe the action that will performed when this API is
called. This name is used in the response to the
RestNodesUsageAction.
-
routes
The list ofRestHandler.Routes that this RestHandler is responsible for handling.- Specified by:
routesin interfaceRestHandler
-
handleRequest
public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws java.lang.ExceptionDescription copied from interface:RestHandlerHandles a rest request.- Specified by:
handleRequestin interfaceRestHandler- Parameters:
request- The request to handlechannel- The channel to write the request response toclient- A client to use to make internal requests on behalf of the original request- Throws:
java.lang.Exception
-
unrecognized
protected final java.lang.String unrecognized(RestRequest request, java.util.Set<java.lang.String> invalids, java.util.Set<java.lang.String> candidates, java.lang.String detail) -
prepareRequest
protected abstract BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws java.io.IOExceptionPrepare the request for execution. Implementations should consume all request params before returning the runnable for actual execution. Unconsumed params will immediately terminate execution of the request. However, some params are only used in processing the response; implementations can overrideresponseParams()to indicate such params.- Parameters:
request- the request to executeclient- client for executing actions on the local node- Returns:
- the action to execute
- Throws:
java.io.IOException- if an I/O exception occurred parsing the request and preparing for execution
-
responseParams
protected java.util.Set<java.lang.String> responseParams()Parameters used for controlling the response and thus might not be consumed during preparation of the request execution inprepareRequest(RestRequest, NodeClient).- Returns:
- a set of parameters used to control the response and thus should not trip strict URL parameter checks.
-