delete-forecast.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. [[java-rest-high-x-pack-ml-delete-forecast]]
  2. === Delete Forecast API
  3. The Delete Forecast API provides the ability to delete a {ml} job's
  4. forecast in the cluster.
  5. It accepts a `DeleteForecastRequest` object and responds
  6. with an `AcknowledgedResponse` object.
  7. [[java-rest-high-x-pack-ml-delete-forecast-request]]
  8. ==== Delete Forecast Request
  9. A `DeleteForecastRequest` object gets created with an existing non-null `jobId`.
  10. All other fields are optional for the request.
  11. ["source","java",subs="attributes,callouts,macros"]
  12. --------------------------------------------------
  13. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-request]
  14. --------------------------------------------------
  15. <1> Constructing a new request referencing an existing `jobId`
  16. ==== Optional Arguments
  17. The following arguments are optional.
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-request-options]
  21. --------------------------------------------------
  22. <1> Sets the specific forecastIds to delete, can be set to `_all` to indicate ALL forecasts for the given
  23. `jobId`
  24. <2> Set the timeout for the request to respond, default is 30 seconds
  25. <3> Set the `allow_no_forecasts` option. When `true` no error will be returned if an `_all`
  26. request finds no forecasts. It defaults to `true`
  27. [[java-rest-high-x-pack-ml-delete-forecast-execution]]
  28. ==== Execution
  29. The request can be executed through the `MachineLearningClient` contained
  30. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-execute]
  34. --------------------------------------------------
  35. [[java-rest-high-x-pack-ml-delete-forecast-execution-async]]
  36. ==== Asynchronous Execution
  37. The request can also be executed asynchronously:
  38. ["source","java",subs="attributes,callouts,macros"]
  39. --------------------------------------------------
  40. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-execute-async]
  41. --------------------------------------------------
  42. <1> The `DeleteForecastRequest` to execute and the `ActionListener` to use when
  43. the execution completes
  44. The method does not block and returns immediately. The passed `ActionListener` is used
  45. to notify the caller of completion. A typical `ActionListener` for `AcknowledgedResponse` may
  46. look like
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-listener]
  50. --------------------------------------------------
  51. <1> `onResponse` is called back when the action is completed successfully
  52. <2> `onFailure` is called back when some unexpected error occurs
  53. [[java-rest-high-x-pack-ml-delete-forecast-response]]
  54. ==== Delete Forecast Response
  55. An `AcknowledgedResponse` contains an acknowledgement of the forecast(s) deletion
  56. ["source","java",subs="attributes,callouts,macros"]
  57. --------------------------------------------------
  58. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-response]
  59. --------------------------------------------------
  60. <1> `isAcknowledged()` indicates if the forecast was successfully deleted or not.