setup:
  - skip:
      features: headers
  - do:
      headers:
        Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      ml.put_job:
        job_id: delete-expired-data-a
        body:  >
          {
            "description":"Analysis of response time by airline",
            "analysis_config" : {
                "bucket_span" : "1h",
                "detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
            },
            "data_description" : {
                "time_field":"time",
                "time_format":"yyyy-MM-dd HH:mm:ssX"
            },
            "results_retention_days" : 1,
            "model_snapshot_retention_days" : 1
          }

  - do:
      headers:
        Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      ml.put_job:
        job_id: delete-expired-data-b
        body:  >
          {
            "description":"Analysis of response time by airline",
            "analysis_config" : {
                "bucket_span" : "1h",
                "detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
            },
            "data_description" : {
                "time_field":"time",
                "time_format":"yyyy-MM-dd HH:mm:ssX"
            },
            "results_retention_days" : 1,
            "model_snapshot_retention_days" : 1
          }

---
"Test delete expired data with no body":
  - do:
      ml.delete_expired_data: {}

  - match: { deleted: true}
---
"Test delete expired data with body parameters":
  - do:
      ml.delete_expired_data:
        body:  >
           { "timeout": "10h", "requests_per_second": 100000.0 }
  - match: { deleted: true}
---
"Test delete expired data with path parameters":
  - do:
      ml.delete_expired_data:
        timeout: "10h"
        requests_per_second: 100000.0
  - match: { deleted: true}
---
"Test delete expired data with unknown job id":
  - do:
      catch: missing
      ml.delete_expired_data:
        job_id: not-a-job
