Skip to content

Commit 949aa77

Browse files
migrates notification server routes to NP
1 parent 63cfffb commit 949aa77

File tree

4 files changed

+46
-28
lines changed

4 files changed

+46
-28
lines changed

x-pack/legacy/plugins/ml/server/new_platform/plugin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { dataFeedRoutes } from '../routes/datafeeds';
3333
import { indicesRoutes } from '../routes/indices';
3434
import { jobValidationRoutes } from '../routes/job_validation';
3535
import { makeMlUsageCollector } from '../lib/ml_telemetry';
36-
// @ts-ignore: could not find declaration file for module
3736
import { notificationRoutes } from '../routes/notification_settings';
3837
// @ts-ignore: could not find declaration file for module
3938
import { systemRoutes } from '../routes/system';

x-pack/legacy/plugins/ml/server/routes/apidoc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
"EstimateBucketSpan",
9393
"CalculateModelMemoryLimit",
9494
"ValidateCardinality",
95-
"ValidateJob"
95+
"ValidateJob",
96+
"NotificationSettings",
97+
"GetNotificationSettings"
9698
]
9799
}

x-pack/legacy/plugins/ml/server/routes/notification_settings.js

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { licensePreRoutingFactory } from '../new_platform/licence_check_pre_routing_factory';
8+
import { wrapError } from '../client/error_wrapper';
9+
import { RouteInitialization } from '../new_platform/plugin';
10+
11+
/**
12+
* Routes for notification settings
13+
*/
14+
export function notificationRoutes({ xpackMainPlugin, router }: RouteInitialization) {
15+
/**
16+
* @apiGroup NotificationSettings
17+
*
18+
* @api {get} /api/ml/notification_settings Get notification settings
19+
* @apiName GetNotificationSettings
20+
* @apiDescription Returns cluster notification settings
21+
*/
22+
router.get(
23+
{
24+
path: '/api/ml/notification_settings',
25+
validate: false,
26+
},
27+
licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => {
28+
try {
29+
const params = {
30+
includeDefaults: true,
31+
filterPath: '**.xpack.notification',
32+
};
33+
const resp = await context.ml!.mlClient.callAsCurrentUser('cluster.getSettings', params);
34+
35+
return response.ok({
36+
body: resp,
37+
});
38+
} catch (e) {
39+
return response.customError(wrapError(e));
40+
}
41+
})
42+
);
43+
}

0 commit comments

Comments
 (0)