use of org.opensearch.rest.action.RestToXContentListener in project anomaly-detection by opensearch-project.
the class RestSearchAnomalyDetectorInfoAction method prepareRequest.
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, org.opensearch.client.node.NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
throw new IllegalStateException(CommonErrorMessages.DISABLED_ERR_MSG);
}
String detectorName = request.param("name", null);
String rawPath = request.rawPath();
SearchAnomalyDetectorInfoRequest searchAnomalyDetectorInfoRequest = new SearchAnomalyDetectorInfoRequest(detectorName, rawPath);
return channel -> client.execute(SearchAnomalyDetectorInfoAction.INSTANCE, searchAnomalyDetectorInfoRequest, new RestToXContentListener<>(channel));
}
use of org.opensearch.rest.action.RestToXContentListener in project ml-commons by opensearch-project.
the class RestMLDeleteModelAction method prepareRequest.
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
String modelId = request.param(PARAMETER_MODEL_ID);
MLModelDeleteRequest mlModelDeleteRequest = new MLModelDeleteRequest(modelId);
return channel -> client.execute(MLModelDeleteAction.INSTANCE, mlModelDeleteRequest, new RestToXContentListener<>(channel));
}
use of org.opensearch.rest.action.RestToXContentListener in project OpenSearch by opensearch-project.
the class RestDeleteIndexTemplateAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name"));
deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", deleteIndexTemplateRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(deleteIndexTemplateRequest, request, deprecationLogger, getName());
return channel -> client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new RestToXContentListener<>(channel));
}
use of org.opensearch.rest.action.RestToXContentListener in project OpenSearch by opensearch-project.
the class RestFlushAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
FlushRequest flushRequest = new FlushRequest(Strings.splitStringByCommaToArray(request.param("index")));
flushRequest.indicesOptions(IndicesOptions.fromRequest(request, flushRequest.indicesOptions()));
flushRequest.force(request.paramAsBoolean("force", flushRequest.force()));
flushRequest.waitIfOngoing(request.paramAsBoolean("wait_if_ongoing", flushRequest.waitIfOngoing()));
return channel -> client.admin().indices().flush(flushRequest, new RestToXContentListener<>(channel));
}
use of org.opensearch.rest.action.RestToXContentListener in project OpenSearch by opensearch-project.
the class RestGetIndicesAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final GetIndexRequest getIndexRequest = new GetIndexRequest();
getIndexRequest.indices(indices);
getIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, getIndexRequest.indicesOptions()));
getIndexRequest.local(request.paramAsBoolean("local", getIndexRequest.local()));
getIndexRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", getIndexRequest.masterNodeTimeout()));
parseDeprecatedMasterTimeoutParameter(getIndexRequest, request, deprecationLogger, getName());
getIndexRequest.humanReadable(request.paramAsBoolean("human", false));
getIndexRequest.includeDefaults(request.paramAsBoolean("include_defaults", false));
return channel -> client.admin().indices().getIndex(getIndexRequest, new RestToXContentListener<>(channel));
}
Aggregations