Skip to content

Commit

Permalink
[8.x] [ML] Removing validate detector endpoint (elastic#198667) (elas…
Browse files Browse the repository at this point in the history
…tic#198898)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Removing validate detector endpoint
(elastic#198667)](elastic#198667)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"James
Gowdy","email":"jgowdy@elastic.co"},"sourceCommit":{"committedDate":"2024-11-05T09:23:00Z","message":"[ML]
Removing validate detector endpoint (elastic#198667)\n\nThe ML UI makes no use
of the validate detector endpoint in es,\r\ntherefore we do not need the
kibana endpoint.\r\nThis can be replaced if we ever do need it, but for
now it's better to\r\nnot have unused internal endpoints exposed in
kibana with no api
tests.","sha":"f33baa36cd4cff9be2b9fb50151be655910b4433","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["non-issue",":ml","Feature:Anomaly
Detection","release_note:skip","v9.0.0","backport:version","v8.17.0"],"title":"[ML]
Removing validate detector
endpoint","number":198667,"url":"https://github.com/elastic/kibana/pull/198667","mergeCommit":{"message":"[ML]
Removing validate detector endpoint (elastic#198667)\n\nThe ML UI makes no use
of the validate detector endpoint in es,\r\ntherefore we do not need the
kibana endpoint.\r\nThis can be replaced if we ever do need it, but for
now it's better to\r\nnot have unused internal endpoints exposed in
kibana with no api
tests.","sha":"f33baa36cd4cff9be2b9fb50151be655910b4433"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198667","number":198667,"mergeCommit":{"message":"[ML]
Removing validate detector endpoint (elastic#198667)\n\nThe ML UI makes no use
of the validate detector endpoint in es,\r\ntherefore we do not need the
kibana endpoint.\r\nThis can be replaced if we ever do need it, but for
now it's better to\r\nnot have unused internal endpoints exposed in
kibana with no api
tests.","sha":"f33baa36cd4cff9be2b9fb50151be655910b4433"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: James Gowdy <jgowdy@elastic.co>
  • Loading branch information
kibanamachine and jgowdyelastic authored Nov 5, 2024
1 parent c6b65d7 commit e932099
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import type {
JobStats,
Datafeed,
CombinedJob,
Detector,
AnalysisConfig,
ModelSnapshot,
IndicesOptions,
Expand Down Expand Up @@ -350,15 +349,6 @@ export function mlApiProvider(httpService: HttpService) {
});
},

validateDetector({ detector }: { detector: Detector }) {
const body = JSON.stringify(detector);
return httpService.http<any>({
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/_validate/detector`,
method: 'POST',
body,
});
},

forecast({
jobId,
duration,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/ml/server/lib/ml_client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export type MlClientParams =
| Parameters<MlClient['updateFilter']>
| Parameters<MlClient['updateJob']>
| Parameters<MlClient['updateModelSnapshot']>
| Parameters<MlClient['validate']>
| Parameters<MlClient['validateDetector']>;
| Parameters<MlClient['validate']>;

export type MlGetADParams = Parameters<MlClient['getJobStats']> | Parameters<MlClient['getJobs']>;

Expand Down
31 changes: 0 additions & 31 deletions x-pack/plugins/ml/server/routes/anomaly_detectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,37 +349,6 @@ export function jobRoutes({ router, routeGuard }: RouteInitialization) {
})
);

router.versioned
.post({
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/_validate/detector`,
access: 'internal',
options: {
tags: ['access:ml:canCreateJob'],
},
summary: 'Validates detector',
description: 'Validates specified detector.',
})
.addVersion(
{
version: '1',
validate: {
request: {
body: schema.any(),
},
},
},
routeGuard.fullLicenseAPIGuard(async ({ mlClient, request, response }) => {
try {
const body = await mlClient.validateDetector({ body: request.body });
return response.ok({
body,
});
} catch (e) {
return response.customError(wrapError(e));
}
})
);

router.versioned
.delete({
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/{jobId}/_forecast/{forecastId}`,
Expand Down

0 comments on commit e932099

Please sign in to comment.