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

@ -13,6 +13,10 @@
} }
}, },
"params": { "params": {
"master_timeout": {
"type": "time",
"description": "Explicit operation timeout for connection to master node"
},
"local": { "local": {
"type": "boolean", "type": "boolean",
"description": "Return local information, do not retrieve the state from master node (default: false)" "description": "Return local information, do not retrieve the state from master node (default: false)"

View File

@ -4,7 +4,10 @@
"methods": ["GET"], "methods": ["GET"],
"url": { "url": {
"path": "/_template/{name}", "path": "/_template/{name}",
"paths": ["/_template", "/_template/{name}"], "paths": [
"/_template",
"/_template/{name}"
],
"parts": { "parts": {
"name": { "name": {
"type": "string", "type": "string",
@ -17,6 +20,10 @@
"type": "boolean", "type": "boolean",
"description": "Return settings in flat format (default: false)" "description": "Return settings in flat format (default: false)"
}, },
"master_timeout": {
"type": "time",
"description": "Explicit operation timeout for connection to master node"
},
"local": { "local": {
"type": "boolean", "type": "boolean",
"description": "Return local information, do not retrieve the state from master node (default: false)" "description": "Return local information, do not retrieve the state from master node (default: false)"

View File

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

View File

@ -46,11 +46,12 @@ setup:
- is_true: test - is_true: test
--- ---
"Get template with flat settings": "Get template with flat settings and master timeout":
- do: - do:
indices.get_template: indices.get_template:
name: test name: test
flat_settings: true flat_settings: true
master_timeout: 1m
- match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} - 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 getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local())); getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
getIndexTemplatesRequest.listenerThreaded(false); getIndexTemplatesRequest.listenerThreaded(false);
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0; 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) { public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(request.param("name")); GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(request.param("name"));
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local())); getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestResponseListener<GetIndexTemplatesResponse>(channel) { client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestResponseListener<GetIndexTemplatesResponse>(channel) {
@Override @Override
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse) { public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse) {