Skip to content

Commit

Permalink
[ML] New Platform server shim: update datafeed routes (#57739)
Browse files Browse the repository at this point in the history
* convert datafeed routes to new platfrom

* update datafeed schema

* consolidate datafeedConfig schema for datafeed + job validation
  • Loading branch information
alvarezmelissa87 authored Feb 20, 2020
1 parent 2623976 commit 3f4640b
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 170 deletions.
31 changes: 31 additions & 0 deletions x-pack/legacy/plugins/ml/server/new_platform/datafeeds_schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { schema } from '@kbn/config-schema';

export const startDatafeedSchema = schema.object({
start: schema.maybe(schema.oneOf([schema.number(), schema.string()])),
end: schema.maybe(schema.oneOf([schema.number(), schema.string()])),
timeout: schema.maybe(schema.any()),
});

export const datafeedConfigSchema = schema.object({
datafeed_id: schema.maybe(schema.string()),
feed_id: schema.maybe(schema.string()),
aggregations: schema.maybe(schema.any()),
aggs: schema.maybe(schema.any()),
chunking_config: schema.maybe(schema.any()),
frequency: schema.maybe(schema.string()),
indices: schema.arrayOf(schema.string()),
indexes: schema.maybe(schema.arrayOf(schema.string())),
job_id: schema.maybe(schema.string()),
query: schema.maybe(schema.any()),
max_empty_searches: schema.maybe(schema.number()),
query_delay: schema.maybe(schema.string()),
script_fields: schema.maybe(schema.any()),
scroll_size: schema.maybe(schema.number()),
delayed_data_check_config: schema.maybe(schema.any()),
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { schema } from '@kbn/config-schema';
import { anomalyDetectionJobSchema } from './anomaly_detectors_schema';
import { datafeedConfigSchema } from './datafeeds_schema';

export const estimateBucketSpanSchema = schema.object({
aggTypes: schema.arrayOf(schema.nullable(schema.string())),
Expand Down Expand Up @@ -38,22 +39,6 @@ export const validateJobSchema = schema.object({
job: schema.object(anomalyDetectionJobSchema),
});

const datafeedConfigSchema = schema.object({
datafeed_id: schema.string(),
aggregations: schema.maybe(schema.any()),
aggs: schema.maybe(schema.any()),
chunking_config: schema.maybe(schema.any()),
frequency: schema.maybe(schema.string()),
indices: schema.arrayOf(schema.string()),
indexes: schema.maybe(schema.arrayOf(schema.string())),
job_id: schema.string(),
query: schema.any(),
query_delay: schema.maybe(schema.string()),
script_fields: schema.maybe(schema.any()),
scroll_size: schema.maybe(schema.number()),
delayed_data_check_config: schema.maybe(schema.any()),
});

export const validateCardinalitySchema = {
...anomalyDetectionJobSchema,
datafeed_config: datafeedConfigSchema,
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/ml/server/new_platform/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { mirrorPluginStatus } from '../../../../server/lib/mirror_plugin_status'
import { LICENSE_TYPE } from '../../common/constants/license';
import { annotationRoutes } from '../routes/annotations';
import { jobRoutes } from '../routes/anomaly_detectors';
// @ts-ignore: could not find declaration file for module
import { dataFeedRoutes } from '../routes/datafeeds';
// @ts-ignore: could not find declaration file for module
import { indicesRoutes } from '../routes/indices';
Expand Down
13 changes: 12 additions & 1 deletion x-pack/legacy/plugins/ml/server/routes/apidoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
"ValidateCardinality",
"ValidateJob",
"NotificationSettings",
"GetNotificationSettings"
"GetNotificationSettings",
"DatafeedService",
"GetDatafeeds",
"GetDatafeed",
"GetDatafeedsStats",
"GetDatafeedStats",
"CreateDatafeed",
"UpdateDatafeed",
"DeleteDatafeed",
"StartDatafeed",
"StopDatafeed",
"PreviewDatafeed"
]
}
152 changes: 0 additions & 152 deletions x-pack/legacy/plugins/ml/server/routes/datafeeds.js

This file was deleted.

Loading

0 comments on commit 3f4640b

Please sign in to comment.