1
0

update-job.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [[java-rest-high-x-pack-ml-update-job]]
  2. === Update Job API
  3. The Update Job API provides the ability to update a {ml} job.
  4. It accepts a `UpdateJobRequest` object and responds
  5. with a `PutJobResponse` object.
  6. [[java-rest-high-x-pack-ml-update-job-request]]
  7. ==== Update Job Request
  8. An `UpdateJobRequest` object gets created with a `JobUpdate` object.
  9. ["source","java",subs="attributes,callouts,macros"]
  10. --------------------------------------------------
  11. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-request]
  12. --------------------------------------------------
  13. <1> Constructing a new request referencing a `JobUpdate` object
  14. ==== Optional Arguments
  15. The `JobUpdate` object has many optional arguments with which to update an existing {ml}
  16. job. An existing, non-null `jobId` must be referenced in its creation.
  17. ["source","java",subs="attributes,callouts,macros"]
  18. --------------------------------------------------
  19. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-options]
  20. --------------------------------------------------
  21. <1> Mandatory, non-null `jobId` referencing an existing {ml} job
  22. <2> Updated description
  23. <3> Updated analysis limits
  24. <4> Updated background persistence interval
  25. <5> Updated analysis config's categorization filters
  26. <6> Updated detectors through the `JobUpdate.DetectorUpdate` object
  27. <7> Updated group membership
  28. <8> Updated result retention
  29. <9> Updated model plot configuration
  30. <10> Updated model snapshot retention setting
  31. <11> Updated custom settings
  32. <12> Updated renormalization window
  33. Included with these options are specific optional `JobUpdate.DetectorUpdate` updates.
  34. ["source","java",subs="attributes,callouts,macros"]
  35. --------------------------------------------------
  36. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-detector-options]
  37. --------------------------------------------------
  38. <1> The index of the detector. `O` means unknown
  39. <2> The optional description of the detector
  40. <3> The `DetectionRule` rules that apply to this detector
  41. [[java-rest-high-x-pack-ml-update-job-execution]]
  42. ==== Execution
  43. The request can be executed through the `MachineLearningClient` contained
  44. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  45. ["source","java",subs="attributes,callouts,macros"]
  46. --------------------------------------------------
  47. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-execute]
  48. --------------------------------------------------
  49. [[java-rest-high-x-pack-ml-update-job-execution-async]]
  50. ==== Asynchronous Execution
  51. The request can also be executed asynchronously:
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-execute-async]
  55. --------------------------------------------------
  56. <1> The `UpdateJobRequest` to execute and the `ActionListener` to use when
  57. the execution completes
  58. The method does not block and returns immediately. The passed `ActionListener` is used
  59. to notify the caller of completion. A typical `ActionListener` for `PutJobResponse` may
  60. look like
  61. ["source","java",subs="attributes,callouts,macros"]
  62. --------------------------------------------------
  63. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-listener]
  64. --------------------------------------------------
  65. <1> `onResponse` is called back when the action is completed successfully
  66. <2> `onFailure` is called back when some unexpected error occurs
  67. [[java-rest-high-x-pack-ml-update-job-response]]
  68. ==== Update Job Response
  69. A `PutJobResponse` contains the updated `Job` object
  70. ["source","java",subs="attributes,callouts,macros"]
  71. --------------------------------------------------
  72. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-response]
  73. --------------------------------------------------
  74. <1> `getResponse()` returns the updated `Job` object