---
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":

  - 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":


  - 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":


  - 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:
      indices.put_alias:
        name: alias

  - do:
      indices.get_alias:
        name: alias

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

---
"put alias with missing name":


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

