setup:

  - do:
      indices.create:
        index: test_index1
        body:
            mappings: { test_type1: { }}

  - do:
      indices.create:
        index: test_index2
        body:
            mappings: { test_type2: { }}
  - do:
      indices.create:
        index: foo
        body:
            mappings: { test_type2: {  }}

---
"delete with _all index":
  - do:
      indices.delete_mapping:
        index: _all
        type: test_type2

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_true: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_false: ''

---
"delete with * index":
  - do:
      indices.delete_mapping:
        index: '*'
        type: test_type2

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_true: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_false: ''

---
"delete with prefix* index":
  - do:
      indices.delete_mapping:
        index: test*
        type: test_type2

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_true: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''

---
"delete with list of indices":

  - do:
      indices.delete_mapping:
        index: test_index1,test_index2
        type: test_type2

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_true: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''

---
"delete with index list and _all type":
  - do:
      indices.delete_mapping:
        index: test_index1,test_index2
        type: _all

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_false: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''


---
"delete with index list and * type":
  - do:
      indices.delete_mapping:
        index: test_index1,test_index2
        type: '*'

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_false: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''


---
"delete with index list and prefix* type":
  - do:
      indices.delete_mapping:
        index: test_index1,test_index2
        type: '*2'

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_true: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''

---
"delete with index list and list of types":
  - do:
      indices.delete_mapping:
        index: test_index1,test_index2
        type: test_type1,test_type2

  - do:
      indices.exists_type:
        index: test_index1
        type: test_type1

  - is_false: ''

  - do:
      indices.exists_type:
        index: test_index2
        type: test_type2

  - is_false: ''

  - do:
      indices.exists_type:
        index: foo
        type: test_type2

  - is_true: ''

---
"check 404 on no matching type":
  - do:
      catch: missing
      indices.delete_mapping:
        index: "*"
        type: "non_existent"

  - do:
      catch: missing
      indices.delete_mapping:
        index: "non_existent"
        type: "test_type1"

---
"check delete with blank index and blank type":
  - do:
      catch: param
      indices.delete_mapping:
        name: "test_type1"

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

