Skip to content

[Component templates] Add APIs#66684

Merged
alisonelizabeth merged 11 commits intoelastic:feature/component_templatesfrom
alisonelizabeth:component_templates/apis
May 27, 2020
Merged

[Component templates] Add APIs#66684
alisonelizabeth merged 11 commits intoelastic:feature/component_templatesfrom
alisonelizabeth:component_templates/apis

Conversation

@alisonelizabeth
Copy link
Copy Markdown
Contributor

@alisonelizabeth alisonelizabeth commented May 15, 2020

This PR adds the server routes for the components templates UI.

Endpoints

  • GET /api/index_management/component_templates

    Fetch all component templates

  • GET /api/index_management/component_templates/<name>

    Fetch single component template

  • DELETE /api/index_management/component_templates/<names>

    Delete one or multiple component templates

  • POST /api/index_management/component_templates

    Create a new component template

    Body args:

    {
     "name": "my_component_template",
     "version": 1, // optional
     "template": { // accepts settings, mappings and aliases
       "settings" : {
         "number_of_shards" : 1
       },
     },
     "_meta": {} // optional
    }
    
  • PUT /api/index_management/component_templates/<component_name>

    Update an existing component template

    Body args:

    {
     "name": "my_component_template",
     "version": 1, // optional
     "template": { // accepts settings, mappings and aliases
       "settings" : {
         "number_of_shards" : 1
       },
     },
     "_meta": {} // optional
    }
    

@alisonelizabeth alisonelizabeth added Feature:Index Management Index and index templates UI Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// release_note:skip Skip the PR/issue when compiling release notes labels May 15, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@alisonelizabeth alisonelizabeth marked this pull request as ready for review May 18, 2020 01:35
@alisonelizabeth alisonelizabeth requested a review from a team as a code owner May 18, 2020 01:35
@alisonelizabeth alisonelizabeth requested a review from sebelga May 18, 2020 01:36
@alisonelizabeth
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great job @alisonelizabeth

import { RouteDependencies } from '../../../types';
import { addBasePath } from '../index';

const bodySchema = schema.object({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to have a validate_schemas.ts like in index templates and import a common schema in both places (create and update).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


expect(testComponentTemplate).to.eql({
name: COMPONENT_NAME,
component_template: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply

component_template: COMPONENT

😊


expect(body).to.eql({
itemsDeleted: [COMPONENT_ONE_NAME],
errors: [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I would have gone in so much details to match the ES error in our tests. ES could change it anytime.

WDYT of testing just this

expect(body.itemsDeleted).to.eql([COMPONENT_ONE_NAME]);
expect(body.errors[0].name).to.eql(COMPONENT_DOES_NOT_EXIST);
expect(body.errors[0].error.msg).to.include('index_template_missing_exception');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! I updated the test.

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@alisonelizabeth alisonelizabeth merged commit 5baef1d into elastic:feature/component_templates May 27, 2020
@alisonelizabeth alisonelizabeth deleted the component_templates/apis branch May 27, 2020 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Index Management Index and index templates UI release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants