From 97e018f1bd287a1cb8b89381f2a974ac2284c75f Mon Sep 17 00:00:00 2001 From: David Kyle Date: Tue, 23 Jan 2018 17:40:41 +0000 Subject: [PATCH] [ML] Return the updated calendar after removing a job (elastic/x-pack-elasticsearch#3690) Original commit: elastic/x-pack-elasticsearch@1bf1f3228bbc6d79dacd15258a1316fff69b826b --- .../xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java | 4 ++-- .../test/resources/rest-api-spec/test/ml/calendar_crud.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java index 749987755b9..54dd6885018 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.action.AcknowledgedRestListener; +import org.elasticsearch.rest.action.RestToXContentListener; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.action.UpdateCalendarJobAction; import org.elasticsearch.xpack.ml.calendars.Calendar; @@ -39,6 +39,6 @@ public class RestDeleteCalendarJobAction extends BaseRestHandler { String jobId = restRequest.param(Job.ID.getPreferredName()); UpdateCalendarJobAction.Request request = new UpdateCalendarJobAction.Request(calendarId, Collections.emptySet(), Collections.singleton(jobId)); - return channel -> client.execute(UpdateCalendarJobAction.INSTANCE, request, new AcknowledgedRestListener<>(channel)); + return channel -> client.execute(UpdateCalendarJobAction.INSTANCE, request, new RestToXContentListener<>(channel)); } } diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml b/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml index fa16bb43bf3..7a78aa6cb51 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml @@ -237,6 +237,8 @@ xpack.ml.delete_calendar_job: calendar_id: "wildlife" job_id: "tiger" + - match: { calendar_id: "wildlife" } + - length: { job_ids: 0 } - do: xpack.ml.get_calendars: