use of org.opensearch.ml.common.transport.model.MLModelDeleteRequest in project ml-commons by opensearch-project.
the class DeleteModelTransportAction method doExecute.
@Override
protected void doExecute(Task task, ActionRequest request, ActionListener<DeleteResponse> actionListener) {
MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.fromActionRequest(request);
String modelId = mlModelDeleteRequest.getModelId();
DeleteRequest deleteRequest = new DeleteRequest(ML_MODEL_INDEX, modelId);
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
client.delete(deleteRequest, new ActionListener<DeleteResponse>() {
@Override
public void onResponse(DeleteResponse deleteResponse) {
log.info("Completed Delete Model Request, model id:{} deleted", modelId);
actionListener.onResponse(deleteResponse);
}
@Override
public void onFailure(Exception e) {
log.error("Failed to delete ML model " + modelId, e);
actionListener.onFailure(e);
}
});
} catch (Exception e) {
log.error("Failed to delete ML model " + modelId, e);
actionListener.onFailure(e);
}
}
use of org.opensearch.ml.common.transport.model.MLModelDeleteRequest in project ml-commons by opensearch-project.
the class MachineLearningNodeClient method deleteModel.
@Override
public void deleteModel(String modelId, ActionListener<DeleteResponse> listener) {
MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder().modelId(modelId).build();
client.execute(MLModelDeleteAction.INSTANCE, mlModelDeleteRequest, ActionListener.wrap(deleteResponse -> {
listener.onResponse(deleteResponse);
}, listener::onFailure));
}
use of org.opensearch.ml.common.transport.model.MLModelDeleteRequest 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));
}
Aggregations