Skip to content

Conversation

@joegallo
Copy link
Contributor

@joegallo joegallo commented Mar 10, 2021

Backport of #70167 by commit plus also backporting the intent of the PR rather than the specific diff of the PR -- hence
c01f860 which is new here.

A good example of the change is RestGetCategoriesAction, here's the before:

    @Override
    public List<ReplacedRoute> replacedRoutes() {
        // TODO: remove deprecated endpoint in 8.0.0
        return Collections.unmodifiableList(Arrays.asList(
            new ReplacedRoute(
                GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
                + Request.CATEGORY_ID.getPreferredName() + "}",
                GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
                + Request.CATEGORY_ID.getPreferredName() + "}"),
            new ReplacedRoute(POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() +
                "}/results/categories/{" + Request.CATEGORY_ID.getPreferredName() + "}",
                POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() +
                "}/results/categories/{" + Request.CATEGORY_ID.getPreferredName() + "}"),
            new ReplacedRoute(
                GET, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories",
                GET, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories"),
            new ReplacedRoute(
                POST, MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories",
                POST, MachineLearning.PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories")
        ));
    }

And the after:

    @Override
    public List<ReplacedRoute> replacedRoutes() {
        // TODO: remove deprecated endpoint in 8.0.0
        return org.elasticsearch.common.collect.List.of(
            new ReplacedRoute(
                GET, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories/{" + CATEGORY_ID + "}",
                GET, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories/{" + CATEGORY_ID + "}"),
            new ReplacedRoute(
                POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories/{" + CATEGORY_ID + "}",
                POST, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories/{" + CATEGORY_ID + "}"),
            new ReplacedRoute(
                GET, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories",
                GET, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories"),
            new ReplacedRoute(
                POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories",
                POST, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/results/categories")
        );
    }

Each concatenated path fits on a single line, which is nice.

@joegallo joegallo requested a review from davidkyle March 10, 2021 15:29
@elasticmachine elasticmachine added the Team:ML Meta label for the ML team label Mar 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@joegallo
Copy link
Contributor Author

joegallo commented Mar 10, 2021

Also quite a bit of this code is going to get touched again as part of the 7.x backport of #69573 (which, of course, is why I'm here to begin with). For example, that PR removes replacedRoutes and deprecatedRoutes entirely, etc. So this code still isn't 100% finished yet.

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

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

LGTM

@joegallo joegallo merged commit 6d6c97f into elastic:7.x Mar 10, 2021
@joegallo joegallo deleted the beautify-ml-routes-7.x branch March 10, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport :ml/Transform Transform Team:ML Meta label for the ML team v7.13.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants