-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add REST API for ComponentTemplate CRUD #53558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dakrone
merged 17 commits into
elastic:master
from
dakrone:itv2-component-template-apis
Mar 17, 2020
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0d1fcfd
Add REST API for ComponentTemplate CRUD
dakrone 9280132
Fix API names in json spec
dakrone d406dc5
Fix yaml test definition
dakrone e2cba26
Fix version in skip
dakrone a312ef9
I think I finally got the right format :|
dakrone d46eca0
Add component apis to exceptions list
dakrone b77411f
Fix yaml test
dakrone 3002266
Remove accidental ! in favor of == false
dakrone f3d46f9
Rejig TransportGetComponentTemplateAction
dakrone 0153f47
Check for empty name in PutComponentTemplateRequest
dakrone 068ecad
Move addition into static method and add unit test
dakrone fe2152a
Collapse request/response objects into the actions
dakrone d8dc5f4
Checkstyle
dakrone e56e63f
Merge branch 'master' into itv2-component-template-apis
elasticmachine f6d11d0
Merge branch 'master' into itv2-component-template-apis
elasticmachine 6c9b76f
Change output format to use arrays
dakrone b2f460b
Merge branch 'master' into itv2-component-template-apis
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
35 changes: 35 additions & 0 deletions
35
rest-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_component_template.json
This file contains hidden or 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 @@ | ||
{ | ||
"cluster.delete_component_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html", | ||
"description":"Deletes a component template" | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_component_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" | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_component_template.json
This file contains hidden or 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,41 @@ | ||
{ | ||
"cluster.get_component_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html", | ||
"description":"Returns one or more component templates" | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_component_template", | ||
"methods":[ | ||
"GET" | ||
] | ||
}, | ||
{ | ||
"path":"/_component_template/{name}", | ||
"methods":[ | ||
"GET" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"list", | ||
"description":"The comma separated names of the component templates" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"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)" | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
rest-api-spec/src/main/resources/rest-api-spec/api/cluster.put_component_template.json
This file contains hidden or 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 @@ | ||
{ | ||
"cluster.put_component_template":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html", | ||
"description":"Creates or updates a component template" | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_component_template/{name}", | ||
"methods":[ | ||
"PUT", | ||
"POST" | ||
], | ||
"parts":{ | ||
"name":{ | ||
"type":"string", | ||
"description":"The name of the template" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"create":{ | ||
"type":"boolean", | ||
"description":"Whether the index template should only be added if new or can also replace an existing one", | ||
"default":false | ||
}, | ||
"timeout":{ | ||
"type":"time", | ||
"description":"Explicit operation timeout" | ||
}, | ||
"master_timeout":{ | ||
"type":"time", | ||
"description":"Specify timeout for connection to master" | ||
} | ||
}, | ||
"body":{ | ||
"description":"The template definition", | ||
"required":true | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
rest-api-spec/src/main/resources/rest-api-spec/test/cluster.component_template/10_basic.yml
This file contains hidden or 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,47 @@ | ||
--- | ||
"Basic CRUD": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: not backported yet | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: test | ||
body: | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
aliases: | ||
aliasname: {} | ||
version: 2 | ||
_meta: | ||
foo: bar | ||
baz: | ||
eggplant: true | ||
|
||
- do: | ||
cluster.get_component_template: | ||
name: test | ||
|
||
- match: {component_templates.0.name: test} | ||
- match: {component_templates.0.component_template.version: 2} | ||
- match: {component_templates.0.component_template._meta: {foo: bar, baz: {eggplant: true}}} | ||
- match: {component_templates.0.component_template.template.settings: {index: {number_of_shards: '1', number_of_replicas: '0'}}} | ||
- match: {component_templates.0.component_template.template.mappings: {properties: {field: {type: keyword}}}} | ||
- match: {component_templates.0.component_template.template.aliases: {aliasname: {}}} | ||
|
||
- do: | ||
cluster.delete_component_template: | ||
name: test | ||
|
||
- do: | ||
catch: missing | ||
cluster.get_component_template: | ||
name: test | ||
|
||
- is_false: test |
This file contains hidden or 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
90 changes: 90 additions & 0 deletions
90
...org/elasticsearch/action/admin/indices/template/delete/DeleteComponentTemplateAction.java
This file contains hidden or 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,90 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.indices.template.delete; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.action.support.master.MasterNodeRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.action.ValidateActions.addValidationError; | ||
|
||
public class DeleteComponentTemplateAction extends ActionType<AcknowledgedResponse> { | ||
|
||
public static final DeleteComponentTemplateAction INSTANCE = new DeleteComponentTemplateAction(); | ||
public static final String NAME = "cluster:admin/component_template/delete"; | ||
|
||
private DeleteComponentTemplateAction() { | ||
super(NAME, AcknowledgedResponse::new); | ||
} | ||
|
||
public static class Request extends MasterNodeRequest<Request> { | ||
|
||
private String name; | ||
|
||
public Request(StreamInput in) throws IOException { | ||
super(in); | ||
name = in.readString(); | ||
} | ||
|
||
public Request() { } | ||
|
||
/** | ||
* Constructs a new delete index request for the specified name. | ||
*/ | ||
public Request(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Set the index template name to delete. | ||
*/ | ||
public Request name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (name == null) { | ||
validationException = addValidationError("name is missing", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
/** | ||
* The index template name to delete. | ||
*/ | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(name); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.