Skip to content

Commit

Permalink
[ML] Removing validate detector endpoint (elastic#198667)
Browse files Browse the repository at this point in the history
The ML UI makes no use of the validate detector endpoint in es,
therefore we do not need the kibana endpoint.
This can be replaced if we ever do need it, but for now it's better to
not have unused internal endpoints exposed in kibana with no api tests.
  • Loading branch information
jgowdyelastic authored Nov 5, 2024
1 parent ae4209e commit f33baa3
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 f33baa3

Please sign in to comment.