---
setup:
# create three indices

  - do:
      indices.create:
        index: test_index1
  - do:
      indices.create:
        index: test_index2
  - do:
      indices.create:
        index: foo

---
"put alias per index":
  - skip:
      version: " - 5.99.99"
      reason:  only requested indices are included in 6.x

  - do:
      indices.put_alias:
        index: test_index1
        name: alias
  - do:
      indices.put_alias:
        index: test_index2
        name: alias

  - do:
      indices.get_alias:
        name: alias

  - match: {test_index1.aliases.alias: {}}

  - match: {test_index2.aliases.alias: {}}

  - is_false: foo

---
"put alias in _all index":

  - do:
      indices.put_alias:
        index: _all
        name: alias

  - do:
      indices.get_alias:
        name: alias

  - match: {test_index1.aliases.alias: {}}
  - match: {test_index2.aliases.alias: {}}
  - match: {foo.aliases.alias: {}}

---
"put alias in * index":


  - do:
      indices.put_alias:
        index: '*'
        name: alias

  - do:
      indices.get_alias:
        name: alias

  - match: {test_index1.aliases.alias: {}}
  - match: {test_index2.aliases.alias: {}}
  - match: {foo.aliases.alias: {}}

---
"put alias prefix* index":
  - skip:
      version: " - 5.99.99"
      reason:  only requested indices are included in 6.x

  - do:
      indices.put_alias:
        index: "test_*"
        name: alias

  - do:
      indices.get_alias:
        name: alias

  - match: {test_index1.aliases.alias: {}}
  - match: {test_index2.aliases.alias: {}}
  - is_false: foo

---
"put alias in list of indices":
  - skip:
      version: " - 5.99.99"
      reason:  only requested indices are included in 6.x

  - do:
      indices.put_alias:
        index: "test_index1,test_index2"
        name: alias

  - do:
      indices.get_alias:
        name: alias

  - match: {test_index1.aliases.alias: {}}
  - match: {test_index2.aliases.alias: {}}
  - is_false: foo

---
"put alias with blank index":


  - do:
      catch: param
      indices.put_alias:
        name: alias


---
"put alias with missing name":


  - do:
      catch: param
      indices.put_alias: {}

