mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Removing unused reset and records endpoints (#161120)
Removing two endpoints in the kibana server which are no longer used by ML on the client side. `/anomaly_detectors/${jobId}/_reset` This has been superseded by `/jobs/reset_jobs` which takes multiple job IDs `/anomaly_detectors/{jobId}/results/records` I believe this has never been used, as it didn't have a client side function. Relates to https://github.com/elastic/kibana/issues/157980
This commit is contained in:
parent
d61c254109
commit
efe196f0c1
3 changed files with 1 additions and 127 deletions
|
@ -20,10 +20,7 @@ import type {
|
|||
} from '../../../../common/types/ml_server_info';
|
||||
import type { MlCapabilitiesResponse } from '../../../../common/types/capabilities';
|
||||
import type { Calendar, CalendarId, UpdateCalendar } from '../../../../common/types/calendars';
|
||||
import type {
|
||||
BucketSpanEstimatorData,
|
||||
ResetJobsResponse,
|
||||
} from '../../../../common/types/job_service';
|
||||
import type { BucketSpanEstimatorData } from '../../../../common/types/job_service';
|
||||
import type {
|
||||
Job,
|
||||
JobStats,
|
||||
|
@ -206,14 +203,6 @@ export function mlApiServicesProvider(httpService: HttpService) {
|
|||
});
|
||||
},
|
||||
|
||||
resetJob({ jobId }: { jobId: string }) {
|
||||
return httpService.http<ResetJobsResponse>({
|
||||
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/${jobId}/_reset`,
|
||||
method: 'POST',
|
||||
version: '1',
|
||||
});
|
||||
},
|
||||
|
||||
estimateBucketSpan(obj: BucketSpanEstimatorData) {
|
||||
const body = JSON.stringify(obj);
|
||||
return httpService.http<BucketSpanEstimatorResponse>({
|
||||
|
|
|
@ -14,7 +14,6 @@ import {
|
|||
anomalyDetectionJobSchema,
|
||||
anomalyDetectionUpdateJobSchema,
|
||||
jobIdSchema,
|
||||
getRecordsSchema,
|
||||
getBucketsSchema,
|
||||
getOverallBucketsSchema,
|
||||
getCategoriesSchema,
|
||||
|
@ -24,7 +23,6 @@ import {
|
|||
updateModelSnapshotsSchema,
|
||||
updateModelSnapshotBodySchema,
|
||||
forceQuerySchema,
|
||||
jobResetQuerySchema,
|
||||
} from './schemas/anomaly_detectors_schema';
|
||||
import { getAuthorizationHeader } from '../lib/request_authorization';
|
||||
|
||||
|
@ -362,53 +360,6 @@ export function jobRoutes({ router, routeGuard }: RouteInitialization) {
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
* @api {post} /internal/ml/anomaly_detectors/:jobId/_reset Reset specified job
|
||||
* @apiName ResetAnomalyDetectorsJob
|
||||
* @apiDescription Resets an anomaly detection job.
|
||||
*
|
||||
* @apiSchema (params) jobIdSchema
|
||||
* @apiSchema (query) jobResetQuerySchema
|
||||
*/
|
||||
router.versioned
|
||||
.post({
|
||||
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/{jobId}/_reset`,
|
||||
access: 'internal',
|
||||
options: {
|
||||
tags: ['access:ml:canCloseJob'],
|
||||
},
|
||||
})
|
||||
.addVersion(
|
||||
{
|
||||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
params: jobIdSchema,
|
||||
query: jobResetQuerySchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
routeGuard.fullLicenseAPIGuard(async ({ mlClient, request, response }) => {
|
||||
try {
|
||||
const options: { job_id: string; wait_for_completion?: boolean } = {
|
||||
// TODO change this to correct resetJob request type
|
||||
job_id: request.params.jobId,
|
||||
...(request.query.wait_for_completion !== undefined
|
||||
? { wait_for_completion: request.query.wait_for_completion }
|
||||
: {}),
|
||||
};
|
||||
const body = await mlClient.resetJob(options);
|
||||
return response.ok({
|
||||
body,
|
||||
});
|
||||
} catch (e) {
|
||||
return response.customError(wrapError(e));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
|
@ -540,52 +491,6 @@ export function jobRoutes({ router, routeGuard }: RouteInitialization) {
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
* @api {post} /internal/ml/anomaly_detectors/:jobId/results/records Retrieves anomaly records for a job.
|
||||
* @apiName GetRecords
|
||||
* @apiDescription Retrieves anomaly records for a job.
|
||||
*
|
||||
* @apiSchema (params) jobIdSchema
|
||||
* @apiSchema (body) getRecordsSchema
|
||||
*
|
||||
* @apiSuccess {Number} count
|
||||
* @apiSuccess {Object[]} records
|
||||
*/
|
||||
router.versioned
|
||||
.post({
|
||||
path: `${ML_INTERNAL_BASE_PATH}/anomaly_detectors/{jobId}/results/records`,
|
||||
access: 'internal',
|
||||
options: {
|
||||
tags: ['access:ml:canGetJobs'],
|
||||
},
|
||||
})
|
||||
.addVersion(
|
||||
{
|
||||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
params: jobIdSchema,
|
||||
body: getRecordsSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
routeGuard.fullLicenseAPIGuard(async ({ mlClient, request, response }) => {
|
||||
try {
|
||||
const body = await mlClient.getRecords({
|
||||
job_id: request.params.jobId,
|
||||
body: request.body,
|
||||
});
|
||||
return response.ok({
|
||||
body,
|
||||
});
|
||||
} catch (e) {
|
||||
return response.customError(wrapError(e));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
|
|
|
@ -145,21 +145,6 @@ export const jobIdSchema = schema.object({
|
|||
jobId: schema.string(),
|
||||
});
|
||||
|
||||
export const getRecordsSchema = schema.object({
|
||||
desc: schema.maybe(schema.boolean()),
|
||||
end: schema.maybe(schema.string()),
|
||||
exclude_interim: schema.maybe(schema.boolean()),
|
||||
page: schema.maybe(
|
||||
schema.object({
|
||||
from: schema.number(),
|
||||
size: schema.number(),
|
||||
})
|
||||
),
|
||||
record_score: schema.maybe(schema.number()),
|
||||
sort: schema.maybe(schema.string()),
|
||||
start: schema.maybe(schema.string()),
|
||||
});
|
||||
|
||||
export const getBucketsSchema = schema.object({
|
||||
anomaly_score: schema.maybe(schema.number()),
|
||||
desc: schema.maybe(schema.boolean()),
|
||||
|
@ -222,11 +207,6 @@ export const updateModelSnapshotBodySchema = schema.object({
|
|||
|
||||
export const forecastAnomalyDetector = schema.object({ duration: schema.any() });
|
||||
|
||||
export const jobResetQuerySchema = schema.object({
|
||||
/** wait for completion */
|
||||
wait_for_completion: schema.maybe(schema.boolean()),
|
||||
});
|
||||
|
||||
export const forceQuerySchema = schema.object({
|
||||
/** force close */
|
||||
force: schema.maybe(schema.boolean()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue