forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrates notification server routes to NP (elastic#57906)
- Loading branch information
1 parent
39d030b
commit d913ecd
Showing
4 changed files
with
46 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
x-pack/legacy/plugins/ml/server/routes/notification_settings.js
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
x-pack/legacy/plugins/ml/server/routes/notification_settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}) | ||
); | ||
} |