forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add REST APIs for IndexTemplateV2Metadata CRUD
This commit adds the get/put/delete APIs for interacting with the now v2 versions of index templates. These APIs are behind the existing `es.itv2_feature_flag_registered` system property feature flag. Relates to elastic#53101
- Loading branch information
Showing
19 changed files
with
1,337 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_index_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"indices.delete_index_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html", | ||
"description":"Deletes an index template." | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_index_template/{name}", | ||
"methods":[ | ||
"DELETE" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The name of the template" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"timeout":{ | ||
"type":"time", | ||
"description":"Explicit operation timeout" | ||
}, | ||
"master_timeout":{ | ||
"type":"time", | ||
"description":"Specify timeout for connection to master" | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_index_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"indices.get_index_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html", | ||
"description":"Returns an index template." | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_index_template", | ||
"methods":[ | ||
"GET" | ||
] | ||
}, | ||
{ | ||
"path":"/_index_template/{name}", | ||
"methods":[ | ||
"GET" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"list", | ||
"description":"The comma separated names of the index templates" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"flat_settings":{ | ||
"type":"boolean", | ||
"description":"Return settings in flat format (default: false)" | ||
}, | ||
"master_timeout":{ | ||
"type":"time", | ||
"description":"Explicit operation timeout for connection to master node" | ||
}, | ||
"local":{ | ||
"type":"boolean", | ||
"description":"Return local information, do not retrieve the state from master node (default: false)" | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_index_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"indices.put_index_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html", | ||
"description":"Creates or updates an index template." | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_index_template/{name}", | ||
"methods":[ | ||
"PUT", | ||
"POST" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The name of the template" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"order":{ | ||
"type":"number", | ||
"description":"The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)" | ||
}, | ||
"create":{ | ||
"type":"boolean", | ||
"description":"Whether the index template should only be added if new or can also replace an existing one", | ||
"default":false | ||
}, | ||
"master_timeout":{ | ||
"type":"time", | ||
"description":"Specify timeout for connection to master" | ||
} | ||
}, | ||
"body":{ | ||
"description":"The template definition", | ||
"required":true | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_index_template/10_basic.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
setup: | ||
- do: | ||
indices.put_index_template: | ||
name: test | ||
body: | ||
index_patterns: test-* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
--- | ||
"Get index template": | ||
|
||
- do: | ||
indices.get_index_template: | ||
name: test | ||
|
||
- match: {index_templates.0.name: test} | ||
- match: {index_templates.0.index_template.index_patterns: ["test-*"]} | ||
- match: {index_templates.0.index_template.template.settings: {index: {number_of_shards: '1', number_of_replicas: '0'}}} | ||
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: keyword}}}} | ||
|
||
--- | ||
"Get all tindex emplates": | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test2 | ||
body: | ||
index_patterns: test2-* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
|
||
- do: | ||
indices.get_index_template: {} | ||
|
||
- length: {index_templates: 2} | ||
|
||
--- | ||
"Get index template with local flag": | ||
|
||
- do: | ||
indices.get_index_template: | ||
name: test | ||
local: true | ||
|
||
- match: {index_templates.0.name: test} |
13 changes: 13 additions & 0 deletions
13
...-spec/src/main/resources/rest-api-spec/test/indices.get_index_template/20_get_missing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
setup: | ||
- do: | ||
indices.delete_index_template: | ||
name: '*' | ||
ignore: 404 | ||
--- | ||
"Get missing template": | ||
|
||
- do: | ||
catch: missing | ||
indices.get_index_template: | ||
name: test | ||
|
100 changes: 100 additions & 0 deletions
100
rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/10_basic.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
"Put index template": | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test | ||
body: | ||
index_patterns: test-* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
indices.get_index_template: | ||
name: test | ||
|
||
- match: {index_templates.0.name: "test"} | ||
- match: {index_templates.0.index_template.index_patterns: ["test-*"]} | ||
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}} | ||
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: keyword}}}} | ||
|
||
--- | ||
"Put multiple index templates": | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test | ||
body: | ||
index_patterns: [test-*, test2-*] | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: text | ||
aliases: | ||
test_alias: {} | ||
test_blias: { routing: b } | ||
test_clias: { filter: { term: { user: kimchy }}} | ||
|
||
- do: | ||
indices.get_index_template: | ||
name: test | ||
|
||
- match: {index_templates.0.index_template.index_patterns: ["test-*", "test2-*"]} | ||
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}} | ||
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: text}}}} | ||
- length: {index_templates.0.index_template.template.aliases: 3} | ||
- is_true: index_templates.0.index_template.template.aliases.test_alias | ||
- match: {index_templates.0.index_template.template.aliases.test_blias.index_routing: "b" } | ||
- match: {index_templates.0.index_template.template.aliases.test_blias.search_routing: "b" } | ||
- match: {index_templates.0.index_template.template.aliases.test_clias.filter.term.user: "kimchy" } | ||
|
||
--- | ||
"Put index template with 'create' flag": | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test2 | ||
body: | ||
index_patterns: test-* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
|
||
- do: | ||
indices.get_index_template: | ||
name: test2 | ||
|
||
- match: {index_templates.0.index_template.index_patterns: ["test-*"]} | ||
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}} | ||
|
||
- do: | ||
catch: bad_request | ||
indices.put_index_template: | ||
name: test2 | ||
create: true | ||
body: | ||
index_patterns: test-* | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
|
||
--- | ||
"Put index template without index_patterns": | ||
|
||
- do: | ||
catch: bad_request | ||
indices.put_index_template: | ||
name: test | ||
body: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.