* [Alerts][License] Define minimum license required for each alert type (#84997) * Define minimum license required for each alert type * fixed typechecks * fixed tests * fixed tests * fixed due to comments * fixed due to comments * removed file * removed casting to LicenseType * [Alerts][License] Add license checks to alerts HTTP APIs and execution (#85223) * [Alerts][License] Add license checks to alerts HTTP APIs and execution * fixed typechecks * resolved conflicts * resolved conflicts * added router tests * fixed typechecks * added license check support for alert task running * fixed typechecks * added integration tests * fixed due to comments * fixed due to comments * fixed tests * fixed typechecks * [Alerting UI][License] Disable alert types in UI when the license doesn't support it. (#85496) * [Alerting UI][License] Disable alert types in UI when the license doesn't support it. * fixed typechecks * added licensing for alert list and details page * fixed multy select menu * fixed due to comments * fixed due to comments * fixed due to comments * fixed typechecks * fixed license error message * fixed license error message * fixed typechecks * fixed license error message Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
/*
|
|
* 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, TypeOf } from '@kbn/config-schema';
|
|
import {
|
|
IRouter,
|
|
RequestHandlerContext,
|
|
KibanaRequest,
|
|
IKibanaResponse,
|
|
KibanaResponseFactory,
|
|
} from 'kibana/server';
|
|
import { ILicenseState } from '../lib/license_state';
|
|
import { verifyApiAccess } from '../lib/license_api_access';
|
|
import { BASE_ALERT_API_PATH } from '../../common';
|
|
|
|
const paramSchema = schema.object({
|
|
id: schema.string(),
|
|
});
|
|
|
|
export const getAlertStateRoute = (router: IRouter, licenseState: ILicenseState) => {
|
|
router.get(
|
|
{
|
|
path: `${BASE_ALERT_API_PATH}/alert/{id}/state`,
|
|
validate: {
|
|
params: paramSchema,
|
|
},
|
|
},
|
|
router.handleLegacyErrors(async function (
|
|
context: RequestHandlerContext,
|
|
req: KibanaRequest<TypeOf<typeof paramSchema>, unknown, unknown>,
|
|
res: KibanaResponseFactory
|
|
): Promise<IKibanaResponse> {
|
|
verifyApiAccess(licenseState);
|
|
if (!context.alerting) {
|
|
return res.badRequest({ body: 'RouteHandlerContext is not registered for alerting' });
|
|
}
|
|
const alertsClient = context.alerting.getAlertsClient();
|
|
const { id } = req.params;
|
|
const state = await alertsClient.getAlertState({ id });
|
|
return state ? res.ok({ body: state }) : res.noContent();
|
|
})
|
|
);
|
|
};
|