Skip to content
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

[Component templates] Add APIs #66684

Conversation

alisonelizabeth
Copy link
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 release_note:skip Skip the PR/issue when compiling release notes labels May 15, 2020
@elasticmachine
Copy link
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
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
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
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
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
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
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
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants