From ec0a74447eeda16fe6fb048a3214855910f144eb Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 7 Mar 2019 15:34:26 +0000 Subject: [PATCH 1/5] Forecast id is optional in delete forecast --- .../xpack/ml/rest/job/RestDeleteForecastAction.java | 3 +++ .../resources/rest-api-spec/test/ml/delete_forecast.yml | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteForecastAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteForecastAction.java index c3316b702552e..85d6281377f10 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteForecastAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteForecastAction.java @@ -36,6 +36,9 @@ public RestDeleteForecastAction(Settings settings, RestController controller) { "}/_forecast/{" + Forecast.FORECAST_ID.getPreferredName() + "}", this, DELETE, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_forecast/{" + Forecast.FORECAST_ID.getPreferredName() + "}", deprecationLogger); + controller.registerHandler( + DELETE, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + + "}/_forecast/", this); } @Override diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/delete_forecast.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/delete_forecast.yml index 4b8c5c83a3fd0..758ad967bfb46 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/delete_forecast.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/delete_forecast.yml @@ -137,3 +137,11 @@ setup: forecast_id: _all allow_no_forecasts: true - match: { acknowledged: true } + +--- +"Test delete all where no forecast_id is set": + - do: + ml.delete_forecast: + job_id: delete-forecast-job + allow_no_forecasts: true + - match: { acknowledged: true } From 4ce1adec62e3ac14a9b8cebfde3b3cce2c0b472f Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 7 Mar 2019 16:18:18 +0000 Subject: [PATCH 2/5] Make get categories with POST consistent and update docs --- docs/reference/ml/apis/get-calendar.asciidoc | 1 + .../rest-api-spec/api/ml.get_calendars.json | 4 +++- .../rest-api-spec/test/ml/calendar_crud.yml | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/reference/ml/apis/get-calendar.asciidoc b/docs/reference/ml/apis/get-calendar.asciidoc index 0bb8a30afaf7f..09e429b1f6de3 100644 --- a/docs/reference/ml/apis/get-calendar.asciidoc +++ b/docs/reference/ml/apis/get-calendar.asciidoc @@ -30,6 +30,7 @@ You can get information for a single calendar or for all calendars by using ==== Request Body +`page`:: `from`::: (integer) Skips the specified number of calendars. diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_calendars.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_calendars.json index 29d0067b5f989..de2e192d7e072 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_calendars.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_calendars.json @@ -24,6 +24,8 @@ } } }, - "body": null + "body": { + "description": "The from and size parameters optionally sent in the body" + } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml index d6a7792db7d0c..b4b5c9ad9da7a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/calendar_crud.yml @@ -127,6 +127,20 @@ - length: { calendars: 1} - match: { calendars.0.calendar_id: calendar2 } + - do: + ml.get_calendars: + body: > + { + "page": { + "from": 1, + "size": 2 + } + } + - match: { count: 3 } + - length: { calendars: 2} + - match: { calendars.0.calendar_id: calendar2 } + - match: { calendars.1.calendar_id: calendar3 } + --- "Test PageParams with ID is invalid": - do: From d7ac2697150acd08e8ff1bc509a84bcdf09ae107 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 7 Mar 2019 17:08:05 +0000 Subject: [PATCH 3/5] Correct docs for scheduled event time format --- docs/reference/ml/apis/eventresource.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference/ml/apis/eventresource.asciidoc b/docs/reference/ml/apis/eventresource.asciidoc index 7999c9744aea0..66e51f73a72ae 100644 --- a/docs/reference/ml/apis/eventresource.asciidoc +++ b/docs/reference/ml/apis/eventresource.asciidoc @@ -13,15 +13,15 @@ An events resource has the following properties: (string) A description of the scheduled event. `end_time`:: - (string) The timestamp for the end of the scheduled event. The datetime string - is in ISO 8601 format. + (string) The timestamp for the end of the scheduled event + in milliseconds since the epoch. `event_id`:: (string) An automatically-generated identifier for the scheduled event. `start_time`:: - (string) The timestamp for the beginning of the scheduled event. The datetime - string is in ISO 8601 format. + (string) The timestamp for the beginning of the scheduled event + in milliseconds since the epoch. For more information, see {xpack-ref}/ml-calendars.html[Calendars and Scheduled Events]. From a69e0fe4d61fa2376e81b056c4c4de8df6add9dc Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 7 Mar 2019 18:11:01 +0000 Subject: [PATCH 4/5] Clarify events can be created with date time strings --- docs/reference/ml/apis/eventresource.asciidoc | 4 ++-- docs/reference/ml/apis/post-calendar-event.asciidoc | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/reference/ml/apis/eventresource.asciidoc b/docs/reference/ml/apis/eventresource.asciidoc index 66e51f73a72ae..dbbf6971b5160 100644 --- a/docs/reference/ml/apis/eventresource.asciidoc +++ b/docs/reference/ml/apis/eventresource.asciidoc @@ -13,14 +13,14 @@ An events resource has the following properties: (string) A description of the scheduled event. `end_time`:: - (string) The timestamp for the end of the scheduled event + (long) The timestamp for the end of the scheduled event in milliseconds since the epoch. `event_id`:: (string) An automatically-generated identifier for the scheduled event. `start_time`:: - (string) The timestamp for the beginning of the scheduled event + (long) The timestamp for the beginning of the scheduled event in milliseconds since the epoch. For more information, see diff --git a/docs/reference/ml/apis/post-calendar-event.asciidoc b/docs/reference/ml/apis/post-calendar-event.asciidoc index 616f9d704ffdc..5d122a5d6d1a8 100644 --- a/docs/reference/ml/apis/post-calendar-event.asciidoc +++ b/docs/reference/ml/apis/post-calendar-event.asciidoc @@ -27,7 +27,9 @@ of which must have a start time, end time, and description. ==== Request Body `events`:: - (array) A list of one of more scheduled events. See <>. + (array) A list of one of more scheduled events. The event's start and end times + may be specified as integer milliseconds since the epoch or as a string in ISO 8601 + format. See <>. ==== Authorization From fd7d4ef9a1c568225bd5f1ec21a6d5fc7c07d477 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Fri, 8 Mar 2019 10:29:07 +0000 Subject: [PATCH 5/5] Use date --- docs/reference/ml/apis/eventresource.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference/ml/apis/eventresource.asciidoc b/docs/reference/ml/apis/eventresource.asciidoc index dbbf6971b5160..6c552b68f368f 100644 --- a/docs/reference/ml/apis/eventresource.asciidoc +++ b/docs/reference/ml/apis/eventresource.asciidoc @@ -13,15 +13,15 @@ An events resource has the following properties: (string) A description of the scheduled event. `end_time`:: - (long) The timestamp for the end of the scheduled event - in milliseconds since the epoch. + (date) The timestamp for the end of the scheduled event + in milliseconds since the epoch or ISO 8601 format. `event_id`:: (string) An automatically-generated identifier for the scheduled event. `start_time`:: - (long) The timestamp for the beginning of the scheduled event - in milliseconds since the epoch. + (date) The timestamp for the beginning of the scheduled event + in milliseconds since the epoch or ISO 8601 format. For more information, see {xpack-ref}/ml-calendars.html[Calendars and Scheduled Events].