delete-job.asciidoc 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. [[java-rest-high-x-pack-ml-delete-job]]
  2. === Delete Job API
  3. [[java-rest-high-x-pack-machine-learning-delete-job-request]]
  4. ==== Delete Job Request
  5. A `DeleteJobRequest` object requires a non-null `jobId`.
  6. ["source","java",subs="attributes,callouts,macros"]
  7. ---------------------------------------------------
  8. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request]
  9. ---------------------------------------------------
  10. <1> Constructing a new request referencing an existing `jobId`
  11. ==== Optional Arguments
  12. The following arguments are optional:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. ---------------------------------------------------
  15. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-force]
  16. ---------------------------------------------------
  17. <1> Use to forcefully delete an opened job;
  18. this method is quicker than closing and deleting the job.
  19. Defaults to `false`.
  20. ["source","java",subs="attributes,callouts,macros"]
  21. ---------------------------------------------------
  22. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-wait-for-completion]
  23. ---------------------------------------------------
  24. <1> Use to set whether the request should wait until the operation has completed before returning.
  25. Defaults to `true`.
  26. [[java-rest-high-x-pack-machine-learning-delete-job-execution]]
  27. ==== Execution
  28. The request can be executed through the `MachineLearningClient` contained
  29. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-execute]
  33. --------------------------------------------------
  34. [[java-rest-high-x-pack-machine-learning-delete-job-response]]
  35. ==== Delete Job Response
  36. The returned `DeleteJobResponse` object contains the acknowledgement of the
  37. job deletion or the deletion task depending on whether the request was set
  38. to wait for completion:
  39. ["source","java",subs="attributes,callouts,macros"]
  40. ---------------------------------------------------
  41. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-response]
  42. ---------------------------------------------------
  43. <1> whether was job deletion was acknowledged or not; will be `null` when set not to wait for completion
  44. <2> the id of the job deletion task; will be `null` when set to wait for completion
  45. [[java-rest-high-x-pack-machine-learning-delete-job-async]]
  46. ==== Delete Job Asynchronously
  47. This request can also be made asynchronously.
  48. ["source","java",subs="attributes,callouts,macros"]
  49. ---------------------------------------------------
  50. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-async]
  51. ---------------------------------------------------
  52. <1> The `DeleteJobRequest` to execute and the `ActionListener` to alert on completion or error.
  53. The deletion request returns immediately. Once the request is completed, the `ActionListener` is
  54. called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when
  55. making the request.
  56. A typical listener for a `DeleteJobRequest` could be defined as follows:
  57. ["source","java",subs="attributes,callouts,macros"]
  58. ---------------------------------------------------
  59. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-listener]
  60. ---------------------------------------------------
  61. <1> The action to be taken when it is completed
  62. <2> What to do when a failure occurs