---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Test delete forecast on missing forecast:
- do:
    catch: "/resource_not_found_exception/"
    ml.delete_forecast:
      job_id: "delete-forecast-job"
      forecast_id: "this-is-a-bad-forecast"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test delete on _all forecasts not allow no forecasts:
- do:
    catch: "/resource_not_found_exception/"
    ml.delete_forecast:
      job_id: "delete-forecast-job"
      forecast_id: "_all"
      allow_no_forecasts: false
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test delete on _all forecasts:
- do:
    ml.delete_forecast:
      job_id: "delete-forecast-job"
      forecast_id: "_all"
      allow_no_forecasts: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- 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
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    acknowledged: true
