Skip to content

Commit

Permalink
Rest: expose master_timeout flag on GET _template & HEAD _template
Browse files Browse the repository at this point in the history
These are master level operation but we currently don't expose this parameter

Closes #9688
  • Loading branch information
bleskes committed Feb 13, 2015
1 parent 51ba120 commit c948078
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
10 changes: 7 additions & 3 deletions rest-api-spec/api/indices.exists_template.json
Expand Up @@ -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)"
Expand Down
31 changes: 19 additions & 12 deletions rest-api-spec/api/indices.get_template.json
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rest-api-spec/test/indices.exists_template/10_basic.yaml
Expand Up @@ -24,6 +24,7 @@ setup:
- do:
indices.exists_template:
name: test
master_timeout: 1m

- is_true: ''

Expand Down
3 changes: 2 additions & 1 deletion rest-api-spec/test/indices.get_template/10_basic.yaml
Expand Up @@ -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'}}
Expand Up @@ -56,6 +56,8 @@ public void handleRequest(final RestRequest request, final RestChannel channel,

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;
Expand Down
Expand Up @@ -46,6 +46,7 @@ public RestHeadIndexTemplateAction(Settings settings, RestController controller,
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) {
Expand Down

0 comments on commit c948078

Please sign in to comment.