Rest: expose `master_timeout` flag on `GET _template` & `HEAD _template`

These are master level operation but we currently don't expose this parameter

Closes #9688
This commit is contained in:
Boaz Leskes 2015-02-13 11:11:02 +01:00
parent 51ba120b54
commit c9480783b3
6 changed files with 32 additions and 16 deletions

View File

@ -7,12 +7,16 @@
"paths": ["/_template/{name}"],
"parts": {
"name": {
"type" : "string",
"required" : true,
"description" : "The name of the template"
"type": "string",
"required": true,
"description": "The name of the template"
}
},
"params": {
"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)"

View File

@ -4,23 +4,30 @@
"methods": ["GET"],
"url": {
"path": "/_template/{name}",
"paths": ["/_template", "/_template/{name}"],
"paths": [
"/_template",
"/_template/{name}"
],
"parts": {
"name": {
"type" : "string",
"required" : false,
"description" : "The name of the template"
"type": "string",
"required": false,
"description": "The name of the template"
}
},
"params": {
"flat_settings": {
"type": "boolean",
"description": "Return settings in flat format (default: false)"
},
"local": {
"type": "boolean",
"description": "Return local information, do not retrieve the state from master node (default: false)"
}
"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)"
}
}
},
"body": null

View File

@ -24,6 +24,7 @@ setup:
- do:
indices.exists_template:
name: test
master_timeout: 1m
- is_true: ''

View File

@ -46,11 +46,12 @@ setup:
- is_true: test
---
"Get template with flat settings":
"Get template with flat settings and master timeout":
- 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'}}

View File

@ -56,6 +56,8 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
getIndexTemplatesRequest.listenerThreaded(false);
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;

View File

@ -46,6 +46,7 @@ public class RestHeadIndexTemplateAction extends BaseRestHandler {
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(request.param("name"));
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestResponseListener<GetIndexTemplatesResponse>(channel) {
@Override
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse) {