setup:
  - do:
      indices.create:
        index: test_index1
        body:
          warmers:
            test_warmer1:
              source:
                query:
                  match_all: {}
            test_warmer2:
              source:
                query:
                  match_all: {}

  - do:
      indices.create:
        index: test_index2
        body:
          warmers:
            test_warmer1:
              source:
                query:
                  match_all: {}
            test_warmer2:
              source:
                query:
                  match_all: {}

  - do:
      indices.create:
        index: foo
        body:
          warmers:
            test_warmer1:
              source:
                query:
                  match_all: {}
            test_warmer2:
              source:
                query:
                  match_all: {}

---
"Check setup":

  - do:
      indices.get_warmer:  { index: _all, name: '*' }

  - match: {test_index1.warmers.test_warmer1.source.query.match_all: {}}
  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer1.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}


---
"check delete with _all index":
  - do:
      indices.delete_warmer:
        index: _all
        name: test_warmer1

  - do:
      indices.get_warmer:  {}

  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}

---
"check delete with * index":
  - do:
      indices.delete_warmer:
        index: "*"
        name: test_warmer1

  - do:
      indices.get_warmer:  {}

  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}

---
"check delete with index list":
  - do:
      indices.delete_warmer:
        index: "test_index1,test_index2"
        name: test_warmer1

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer1' }

  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer2' }

  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}

---
"check delete with prefix* index":
  - do:
      indices.delete_warmer:
        index: "test_*"
        name: test_warmer1

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer1' }

  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer2' }

  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}


---
"check delete with index list and * warmers":
  - do:
      indices.delete_warmer:
        index: "test_index1,test_index2"
        name: "*"

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer1' }

  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

  - do:
      indices.get_warmer:  { index: _all, name: 'test_warmer2' }

  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

---
"check delete with index list and _all warmers":
  - do:
      indices.delete_warmer:
        index: "test_index1,test_index2"
        name: _all

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer1' }

  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer2' }

  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

---
"check delete with index list and wildcard warmers":
  - do:
      indices.delete_warmer:
        index: "test_index1,test_index2"
        name: "*1"

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer1' }

  - match: {foo.warmers.test_warmer1.source.query.match_all: {}}
  - is_false: test_index1
  - is_false: test_index2

  - do:
      indices.get_warmer: { index: _all, name: 'test_warmer2' }

  - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
  - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
  - match: {foo.warmers.test_warmer2.source.query.match_all: {}}

---
"check 404 on no matching test_warmer":
  - do:
      catch: missing
      indices.delete_warmer:
        index: "*"
        name: "non_existent"

  - do:
      catch: missing
      indices.delete_warmer:
        index: "non_existent"
        name: "test_warmer1"


---
"check delete with blank index and blank test_warmer":
  - do:
      catch: param
      indices.delete_warmer:
        name: "test_warmer1"

  - do:
      catch: param
      indices.delete_warmer:
        index: "test_index1"

