setup:
  - do:
      indices.put_template:
        name: test
        body:
          index_patterns: test-*
          settings:
            number_of_shards:   1
            number_of_replicas: 0

---
"Get template":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new API that has been added in 6.0

  - do:
      indices.get_template:
        name: test

  - match: {test.index_patterns: ["test-*"]}
  - match: {test.settings: {index: {number_of_shards: '1', number_of_replicas: '0'}}}

---
"Get all templates":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new API that has been added in 6.0

  - do:
      indices.put_template:
        name: test2
        body:
          index_patterns: test2-*
          settings:
            number_of_shards:   1

  - do:
      indices.get_template: {}

  - match: {test.index_patterns: ["test-*"]}
  - match: {test2.index_patterns: ["test2-*"]}

---
"Get template with local flag":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new API that has been added in 6.0

  - do:
      indices.get_template:
        name: test
        local: true

  - is_true: test

---
"Get template with flat settings and master timeout":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new API that has been added in 6.0

  - do:
      indices.get_template:
        name: test
        flat_settings: true
        master_timeout: 1m

  - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}}
