Skip to content

Commit

Permalink
migrates notification server routes to NP (elastic#57906)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Feb 20, 2020
1 parent 39d030b commit d913ecd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 28 deletions.
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 @@ -33,7 +33,6 @@ import { dataFeedRoutes } from '../routes/datafeeds';
import { indicesRoutes } from '../routes/indices';
import { jobValidationRoutes } from '../routes/job_validation';
import { makeMlUsageCollector } from '../lib/ml_telemetry';
// @ts-ignore: could not find declaration file for module
import { notificationRoutes } from '../routes/notification_settings';
// @ts-ignore: could not find declaration file for module
import { systemRoutes } from '../routes/system';
Expand Down
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/ml/server/routes/apidoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
"EstimateBucketSpan",
"CalculateModelMemoryLimit",
"ValidateCardinality",
"ValidateJob"
"ValidateJob",
"NotificationSettings",
"GetNotificationSettings"
]
}
26 changes: 0 additions & 26 deletions x-pack/legacy/plugins/ml/server/routes/notification_settings.js

This file was deleted.

43 changes: 43 additions & 0 deletions x-pack/legacy/plugins/ml/server/routes/notification_settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 { licensePreRoutingFactory } from '../new_platform/licence_check_pre_routing_factory';
import { wrapError } from '../client/error_wrapper';
import { RouteInitialization } from '../new_platform/plugin';

/**
* Routes for notification settings
*/
export function notificationRoutes({ xpackMainPlugin, router }: RouteInitialization) {
/**
* @apiGroup NotificationSettings
*
* @api {get} /api/ml/notification_settings Get notification settings
* @apiName GetNotificationSettings
* @apiDescription Returns cluster notification settings
*/
router.get(
{
path: '/api/ml/notification_settings',
validate: false,
},
licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => {
try {
const params = {
includeDefaults: true,
filterPath: '**.xpack.notification',
};
const resp = await context.ml!.mlClient.callAsCurrentUser('cluster.getSettings', params);

return response.ok({
body: resp,
});
} catch (e) {
return response.customError(wrapError(e));
}
})
);
}

0 comments on commit d913ecd

Please sign in to comment.