|
| 1 | +[[java-rest-high-x-pack-ml-delete-calendar]] |
| 2 | +=== Delete Calendar API |
| 3 | +Delete a {ml} calendar. |
| 4 | +The API accepts a `DeleteCalendarRequest` and responds |
| 5 | +with a `AcknowledgedResponse` object. |
| 6 | + |
| 7 | +[[java-rest-high-x-pack-ml-delete-calendar-request]] |
| 8 | +==== Delete Calendar Request |
| 9 | + |
| 10 | +A `DeleteCalendar` object requires a non-null `calendarId`. |
| 11 | + |
| 12 | +["source","java",subs="attributes,callouts,macros"] |
| 13 | +--------------------------------------------------- |
| 14 | +include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-request] |
| 15 | +--------------------------------------------------- |
| 16 | +<1> Constructing a new request referencing an existing Calendar |
| 17 | + |
| 18 | +[[java-rest-high-x-pack-ml-delete-calendar-response]] |
| 19 | +==== Delete Calendar Response |
| 20 | + |
| 21 | +The returned `AcknowledgedResponse` object indicates the acknowledgement of the request: |
| 22 | +["source","java",subs="attributes,callouts,macros"] |
| 23 | +--------------------------------------------------- |
| 24 | +include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-response] |
| 25 | +--------------------------------------------------- |
| 26 | +<1> `isAcknowledged` was the deletion request acknowledged or not |
| 27 | + |
| 28 | +[[java-rest-high-x-pack-ml-delete-calendar-execution]] |
| 29 | +==== Execution |
| 30 | +The request can be executed through the `MachineLearningClient` contained |
| 31 | +in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method. |
| 32 | + |
| 33 | +["source","java",subs="attributes,callouts,macros"] |
| 34 | +-------------------------------------------------- |
| 35 | +include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-execute] |
| 36 | +-------------------------------------------------- |
| 37 | + |
| 38 | +[[java-rest-high-x-pack-ml-delete-calendar-async]] |
| 39 | +==== Delete Calendar Asynchronously |
| 40 | + |
| 41 | +This request can also be made asynchronously. |
| 42 | +["source","java",subs="attributes,callouts,macros"] |
| 43 | +--------------------------------------------------- |
| 44 | +include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-execute-async] |
| 45 | +--------------------------------------------------- |
| 46 | +<1> The `DeleteCalendarRequest` to execute and the `ActionListener` to alert on completion or error. |
| 47 | + |
| 48 | +The deletion request returns immediately. Once the request is completed, the `ActionListener` is |
| 49 | +called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when |
| 50 | +making the request. |
| 51 | + |
| 52 | +A typical listener for a `DeleteCalendarRequest` could be defined as follows: |
| 53 | + |
| 54 | +["source","java",subs="attributes,callouts,macros"] |
| 55 | +--------------------------------------------------- |
| 56 | +include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-listener] |
| 57 | +--------------------------------------------------- |
| 58 | +<1> The action to be taken when it is completed |
| 59 | +<2> What to do when a failure occurs |
0 commit comments