diff --git a/x-pack/plugins/alerting/server/lib/index.ts b/x-pack/plugins/alerting/server/lib/index.ts index 3fd0ac403f8f8..8c082aed345d7 100644 --- a/x-pack/plugins/alerting/server/lib/index.ts +++ b/x-pack/plugins/alerting/server/lib/index.ts @@ -6,7 +6,7 @@ */ export { parseDuration, validateDurationSchema } from '../../common/parse_duration'; -export { LicenseState } from './license_state'; +export { ILicenseState, LicenseState } from './license_state'; export { validateAlertTypeParams } from './validate_alert_type_params'; export { getAlertNotifyWhenType } from './get_alert_notify_when_type'; export { ErrorWithReason, getReasonFromError, isErrorWithReason } from './error_with_reason'; diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index d85622f301171..a4e76af13234e 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -38,25 +38,7 @@ import { } from '../../../../src/core/server'; import type { AlertingRequestHandlerContext } from './types'; -import { - aggregateAlertRoute, - createAlertRoute, - deleteAlertRoute, - findAlertRoute, - getAlertRoute, - getAlertStateRoute, - getAlertInstanceSummaryRoute, - listAlertTypesRoute, - updateAlertRoute, - enableAlertRoute, - disableAlertRoute, - updateApiKeyRoute, - muteAllAlertRoute, - unmuteAllAlertRoute, - muteAlertInstanceRoute, - unmuteAlertInstanceRoute, - healthRoute, -} from './routes'; +import { defineRoutes } from './routes'; import { LICENSE_TYPE, LicensingPluginSetup, LicensingPluginStart } from '../../licensing/server'; import { PluginSetupContract as ActionsPluginSetupContract, @@ -267,23 +249,7 @@ export class AlertingPlugin { // Routes const router = core.http.createRouter(); // Register routes - aggregateAlertRoute(router, this.licenseState); - createAlertRoute(router, this.licenseState); - deleteAlertRoute(router, this.licenseState); - findAlertRoute(router, this.licenseState); - getAlertRoute(router, this.licenseState); - getAlertStateRoute(router, this.licenseState); - getAlertInstanceSummaryRoute(router, this.licenseState); - listAlertTypesRoute(router, this.licenseState); - updateAlertRoute(router, this.licenseState); - enableAlertRoute(router, this.licenseState); - disableAlertRoute(router, this.licenseState); - updateApiKeyRoute(router, this.licenseState); - muteAllAlertRoute(router, this.licenseState); - unmuteAllAlertRoute(router, this.licenseState); - muteAlertInstanceRoute(router, this.licenseState); - unmuteAlertInstanceRoute(router, this.licenseState); - healthRoute(router, this.licenseState, plugins.encryptedSavedObjects); + defineRoutes(router, this.licenseState, plugins.encryptedSavedObjects); return { registerType< diff --git a/x-pack/plugins/alerting/server/routes/index.ts b/x-pack/plugins/alerting/server/routes/index.ts index e250d17866a2b..e10fb05b6f803 100644 --- a/x-pack/plugins/alerting/server/routes/index.ts +++ b/x-pack/plugins/alerting/server/routes/index.ts @@ -5,20 +5,16 @@ * 2.0. */ -export { aggregateAlertRoute } from './aggregate'; -export { createAlertRoute } from './create'; -export { deleteAlertRoute } from './delete'; -export { findAlertRoute } from './find'; -export { getAlertRoute } from './get'; -export { getAlertStateRoute } from './get_alert_state'; -export { getAlertInstanceSummaryRoute } from './get_alert_instance_summary'; -export { listAlertTypesRoute } from './list_alert_types'; -export { updateAlertRoute } from './update'; -export { enableAlertRoute } from './enable'; -export { disableAlertRoute } from './disable'; -export { updateApiKeyRoute } from './update_api_key'; -export { muteAlertInstanceRoute } from './mute_instance'; -export { unmuteAlertInstanceRoute } from './unmute_instance'; -export { muteAllAlertRoute } from './mute_all'; -export { unmuteAllAlertRoute } from './unmute_all'; -export { healthRoute } from './health'; +import { IRouter } from 'kibana/server'; +import { ILicenseState } from '../lib'; +import { defineLegacyRoutes } from './legacy'; +import { AlertingRequestHandlerContext } from '../types'; +import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server'; + +export function defineRoutes( + router: IRouter, + licenseState: ILicenseState, + encryptedSavedObjects: EncryptedSavedObjectsPluginSetup +) { + defineLegacyRoutes(router, licenseState, encryptedSavedObjects); +} diff --git a/x-pack/plugins/alerting/server/routes/aggregate.test.ts b/x-pack/plugins/alerting/server/routes/legacy/aggregate.test.ts similarity index 91% rename from x-pack/plugins/alerting/server/routes/aggregate.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/aggregate.test.ts index 60e9a2a1bcc79..94331902d9ace 100644 --- a/x-pack/plugins/alerting/server/routes/aggregate.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/aggregate.test.ts @@ -7,14 +7,14 @@ import { aggregateAlertRoute } from './aggregate'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/aggregate.ts b/x-pack/plugins/alerting/server/routes/legacy/aggregate.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/aggregate.ts rename to x-pack/plugins/alerting/server/routes/legacy/aggregate.ts index 1416f60277daa..dc54176043de0 100644 --- a/x-pack/plugins/alerting/server/routes/aggregate.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/aggregate.ts @@ -6,12 +6,12 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { renameKeys } from './lib/rename_keys'; -import { FindOptions } from '../alerts_client'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { renameKeys } from './../lib/rename_keys'; +import { FindOptions } from '../../alerts_client'; // config definition const querySchema = schema.object({ diff --git a/x-pack/plugins/alerting/server/routes/create.test.ts b/x-pack/plugins/alerting/server/routes/legacy/create.test.ts similarity index 93% rename from x-pack/plugins/alerting/server/routes/create.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/create.test.ts index 1a2dfec8612e3..fd3252d2fca77 100644 --- a/x-pack/plugins/alerting/server/routes/create.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/create.test.ts @@ -7,16 +7,16 @@ import { createAlertRoute } from './create'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { Alert } from '../../common/alert'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { Alert } from '../../../common/alert'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/create.ts b/x-pack/plugins/alerting/server/routes/legacy/create.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/create.ts rename to x-pack/plugins/alerting/server/routes/legacy/create.ts index 7b1a518112ddd..2f6a258344cdd 100644 --- a/x-pack/plugins/alerting/server/routes/create.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/create.ts @@ -6,19 +6,19 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { validateDurationSchema } from '../lib'; -import { handleDisabledApiKeysError } from './lib/error_handler'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { validateDurationSchema } from '../../lib'; +import { handleDisabledApiKeysError } from './../lib/error_handler'; import { Alert, AlertNotifyWhenType, AlertTypeParams, BASE_ALERT_API_PATH, validateNotifyWhenType, -} from '../types'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +} from '../../types'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; export const bodySchema = schema.object({ name: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/delete.test.ts b/x-pack/plugins/alerting/server/routes/legacy/delete.test.ts similarity index 89% rename from x-pack/plugins/alerting/server/routes/delete.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/delete.test.ts index 47564f67d42a5..e71b2788b98c7 100644 --- a/x-pack/plugins/alerting/server/routes/delete.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/delete.test.ts @@ -7,14 +7,14 @@ import { deleteAlertRoute } from './delete'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/delete.ts b/x-pack/plugins/alerting/server/routes/legacy/delete.ts similarity index 81% rename from x-pack/plugins/alerting/server/routes/delete.ts rename to x-pack/plugins/alerting/server/routes/legacy/delete.ts index e217fd0533771..e4a551d0b6bf6 100644 --- a/x-pack/plugins/alerting/server/routes/delete.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/delete.ts @@ -6,10 +6,10 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; +import type { AlertingRouter } from '../../types'; +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(), diff --git a/x-pack/plugins/alerting/server/routes/disable.test.ts b/x-pack/plugins/alerting/server/routes/legacy/disable.test.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/disable.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/disable.test.ts index 347b1641515e6..34c0af711a338 100644 --- a/x-pack/plugins/alerting/server/routes/disable.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/disable.test.ts @@ -7,14 +7,14 @@ import { disableAlertRoute } from './disable'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/disable.ts b/x-pack/plugins/alerting/server/routes/legacy/disable.ts similarity index 79% rename from x-pack/plugins/alerting/server/routes/disable.ts rename to x-pack/plugins/alerting/server/routes/legacy/disable.ts index 7129fbdd52698..6b95e391a6963 100644 --- a/x-pack/plugins/alerting/server/routes/disable.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/disable.ts @@ -6,11 +6,11 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/enable.test.ts b/x-pack/plugins/alerting/server/routes/legacy/enable.test.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/enable.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/enable.test.ts index c12a19fc35dbe..88229472a2936 100644 --- a/x-pack/plugins/alerting/server/routes/enable.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/enable.test.ts @@ -7,14 +7,14 @@ import { enableAlertRoute } from './enable'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/enable.ts b/x-pack/plugins/alerting/server/routes/legacy/enable.ts similarity index 76% rename from x-pack/plugins/alerting/server/routes/enable.ts rename to x-pack/plugins/alerting/server/routes/legacy/enable.ts index d874e9b6106b9..28c4ead2d5ef4 100644 --- a/x-pack/plugins/alerting/server/routes/enable.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/enable.ts @@ -6,12 +6,12 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { handleDisabledApiKeysError } from './lib/error_handler'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { handleDisabledApiKeysError } from './../lib/error_handler'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/find.test.ts b/x-pack/plugins/alerting/server/routes/legacy/find.test.ts similarity index 91% rename from x-pack/plugins/alerting/server/routes/find.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/find.test.ts index 791e2babc062e..640451afcca97 100644 --- a/x-pack/plugins/alerting/server/routes/find.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/find.test.ts @@ -7,14 +7,14 @@ import { findAlertRoute } from './find'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/find.ts b/x-pack/plugins/alerting/server/routes/legacy/find.ts similarity index 88% rename from x-pack/plugins/alerting/server/routes/find.ts rename to x-pack/plugins/alerting/server/routes/legacy/find.ts index ad345de685266..0f6d8adaa9881 100644 --- a/x-pack/plugins/alerting/server/routes/find.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/find.ts @@ -6,13 +6,13 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; +import type { AlertingRouter } from '../../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { renameKeys } from './lib/rename_keys'; -import { FindOptions } from '../alerts_client'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { renameKeys } from './../lib/rename_keys'; +import { FindOptions } from '../../alerts_client'; // config definition const querySchema = schema.object({ diff --git a/x-pack/plugins/alerting/server/routes/get.test.ts b/x-pack/plugins/alerting/server/routes/legacy/get.test.ts similarity index 90% rename from x-pack/plugins/alerting/server/routes/get.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/get.test.ts index 79938e572dfcf..b2704cdd234f1 100644 --- a/x-pack/plugins/alerting/server/routes/get.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get.test.ts @@ -7,14 +7,14 @@ import { getAlertRoute } from './get'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { Alert } from '../../common'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { Alert } from '../../../common'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/get.ts b/x-pack/plugins/alerting/server/routes/legacy/get.ts similarity index 81% rename from x-pack/plugins/alerting/server/routes/get.ts rename to x-pack/plugins/alerting/server/routes/legacy/get.ts index 93d2f29f53c18..3dc7283727b92 100644 --- a/x-pack/plugins/alerting/server/routes/get.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get.ts @@ -6,10 +6,10 @@ */ import { schema } from '@kbn/config-schema'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import type { AlertingRouter } from '../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import type { AlertingRouter } from '../../types'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/get_alert_instance_summary.test.ts b/x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.test.ts similarity index 89% rename from x-pack/plugins/alerting/server/routes/get_alert_instance_summary.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.test.ts index 3157f18afbb95..0162ef91f55e7 100644 --- a/x-pack/plugins/alerting/server/routes/get_alert_instance_summary.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.test.ts @@ -7,14 +7,14 @@ import { getAlertInstanceSummaryRoute } from './get_alert_instance_summary'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; import { SavedObjectsErrorHelpers } from 'src/core/server'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertInstanceSummary } from '../types'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertInstanceSummary } from '../../types'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/get_alert_instance_summary.ts b/x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.ts similarity index 84% rename from x-pack/plugins/alerting/server/routes/get_alert_instance_summary.ts rename to x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.ts index 71c85caa38c8d..18e8bf9fb32cc 100644 --- a/x-pack/plugins/alerting/server/routes/get_alert_instance_summary.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get_alert_instance_summary.ts @@ -6,10 +6,10 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; +import type { AlertingRouter } from '../../types'; +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(), diff --git a/x-pack/plugins/alerting/server/routes/get_alert_state.test.ts b/x-pack/plugins/alerting/server/routes/legacy/get_alert_state.test.ts similarity index 93% rename from x-pack/plugins/alerting/server/routes/get_alert_state.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/get_alert_state.test.ts index 5aa96d6c73447..f08e0992cbba0 100644 --- a/x-pack/plugins/alerting/server/routes/get_alert_state.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get_alert_state.test.ts @@ -7,13 +7,13 @@ import { getAlertStateRoute } from './get_alert_state'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; import { SavedObjectsErrorHelpers } from 'src/core/server'; -import { alertsClientMock } from '../alerts_client.mock'; +import { alertsClientMock } from '../../alerts_client.mock'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/get_alert_state.ts b/x-pack/plugins/alerting/server/routes/legacy/get_alert_state.ts similarity index 82% rename from x-pack/plugins/alerting/server/routes/get_alert_state.ts rename to x-pack/plugins/alerting/server/routes/legacy/get_alert_state.ts index 3a05946162d37..e0150957d7d1e 100644 --- a/x-pack/plugins/alerting/server/routes/get_alert_state.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/get_alert_state.ts @@ -6,10 +6,10 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; +import type { AlertingRouter } from '../../types'; +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(), diff --git a/x-pack/plugins/alerting/server/routes/health.test.ts b/x-pack/plugins/alerting/server/routes/legacy/health.test.ts similarity index 94% rename from x-pack/plugins/alerting/server/routes/health.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/health.test.ts index 22df0e6a00046..c1888473c6ac5 100644 --- a/x-pack/plugins/alerting/server/routes/health.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/health.test.ts @@ -7,17 +7,17 @@ import { healthRoute } from './health'; import { httpServiceMock } from 'src/core/server/mocks'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { encryptedSavedObjectsMock } from '../../../encrypted_saved_objects/server/mocks'; -import { alertsClientMock } from '../alerts_client.mock'; -import { HealthStatus } from '../types'; -import { alertsMock } from '../mocks'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { encryptedSavedObjectsMock } from '../../../../encrypted_saved_objects/server/mocks'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { HealthStatus } from '../../types'; +import { alertsMock } from '../../mocks'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/health.ts b/x-pack/plugins/alerting/server/routes/legacy/health.ts similarity index 85% rename from x-pack/plugins/alerting/server/routes/health.ts rename to x-pack/plugins/alerting/server/routes/legacy/health.ts index 9e1f01041e091..2ad557bb8154b 100644 --- a/x-pack/plugins/alerting/server/routes/health.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/health.ts @@ -5,11 +5,11 @@ * 2.0. */ -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { AlertingFrameworkHealth } from '../types'; -import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { AlertingFrameworkHealth } from '../../types'; +import { EncryptedSavedObjectsPluginSetup } from '../../../../encrypted_saved_objects/server'; interface XPackUsageSecurity { security?: { diff --git a/x-pack/plugins/alerting/server/routes/legacy/index.ts b/x-pack/plugins/alerting/server/routes/legacy/index.ts new file mode 100644 index 0000000000000..d1b2f9784f24d --- /dev/null +++ b/x-pack/plugins/alerting/server/routes/legacy/index.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { IRouter } from 'kibana/server'; +import { ILicenseState } from '../../lib'; +import { AlertingRequestHandlerContext } from '../../types'; +import { EncryptedSavedObjectsPluginSetup } from '../../../../encrypted_saved_objects/server'; + +import { aggregateAlertRoute } from './aggregate'; +import { createAlertRoute } from './create'; +import { deleteAlertRoute } from './delete'; +import { findAlertRoute } from './find'; +import { getAlertRoute } from './get'; +import { getAlertStateRoute } from './get_alert_state'; +import { getAlertInstanceSummaryRoute } from './get_alert_instance_summary'; +import { listAlertTypesRoute } from './list_alert_types'; +import { updateAlertRoute } from './update'; +import { enableAlertRoute } from './enable'; +import { disableAlertRoute } from './disable'; +import { updateApiKeyRoute } from './update_api_key'; +import { muteAlertInstanceRoute } from './mute_instance'; +import { unmuteAlertInstanceRoute } from './unmute_instance'; +import { muteAllAlertRoute } from './mute_all'; +import { unmuteAllAlertRoute } from './unmute_all'; +import { healthRoute } from './health'; + +export function defineLegacyRoutes( + router: IRouter, + licenseState: ILicenseState, + encryptedSavedObjects: EncryptedSavedObjectsPluginSetup +) { + aggregateAlertRoute(router, licenseState); + createAlertRoute(router, licenseState); + deleteAlertRoute(router, licenseState); + findAlertRoute(router, licenseState); + getAlertRoute(router, licenseState); + getAlertStateRoute(router, licenseState); + getAlertInstanceSummaryRoute(router, licenseState); + listAlertTypesRoute(router, licenseState); + updateAlertRoute(router, licenseState); + enableAlertRoute(router, licenseState); + disableAlertRoute(router, licenseState); + updateApiKeyRoute(router, licenseState); + muteAllAlertRoute(router, licenseState); + unmuteAllAlertRoute(router, licenseState); + muteAlertInstanceRoute(router, licenseState); + unmuteAlertInstanceRoute(router, licenseState); + healthRoute(router, licenseState, encryptedSavedObjects); +} diff --git a/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts b/x-pack/plugins/alerting/server/routes/legacy/list_alert_types.test.ts similarity index 92% rename from x-pack/plugins/alerting/server/routes/list_alert_types.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/list_alert_types.test.ts index 5ef2e8cc9ec7d..3e6f2f484a6d8 100644 --- a/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/list_alert_types.test.ts @@ -7,16 +7,16 @@ import { listAlertTypesRoute } from './list_alert_types'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { RecoveredActionGroup } from '../../common'; -import { RegistryAlertTypeWithAuth } from '../authorization'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { RecoveredActionGroup } from '../../../common'; +import { RegistryAlertTypeWithAuth } from '../../authorization'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/list_alert_types.ts b/x-pack/plugins/alerting/server/routes/legacy/list_alert_types.ts similarity index 78% rename from x-pack/plugins/alerting/server/routes/list_alert_types.ts rename to x-pack/plugins/alerting/server/routes/legacy/list_alert_types.ts index 2040f71f8ad05..e38bab5504017 100644 --- a/x-pack/plugins/alerting/server/routes/list_alert_types.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/list_alert_types.ts @@ -5,10 +5,10 @@ * 2.0. */ -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; export const listAlertTypesRoute = (router: AlertingRouter, licenseState: ILicenseState) => { router.get( diff --git a/x-pack/plugins/alerting/server/routes/mute_all.test.ts b/x-pack/plugins/alerting/server/routes/legacy/mute_all.test.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/mute_all.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/mute_all.test.ts index 8c938d71ab06c..ffe893fa60490 100644 --- a/x-pack/plugins/alerting/server/routes/mute_all.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/mute_all.test.ts @@ -7,13 +7,13 @@ import { muteAllAlertRoute } from './mute_all'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/mute_all.ts b/x-pack/plugins/alerting/server/routes/legacy/mute_all.ts similarity index 79% rename from x-pack/plugins/alerting/server/routes/mute_all.ts rename to x-pack/plugins/alerting/server/routes/legacy/mute_all.ts index fee1fdfe5a4f7..10a913780e3ef 100644 --- a/x-pack/plugins/alerting/server/routes/mute_all.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/mute_all.ts @@ -6,11 +6,11 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/mute_instance.test.ts b/x-pack/plugins/alerting/server/routes/legacy/mute_instance.test.ts similarity index 87% rename from x-pack/plugins/alerting/server/routes/mute_instance.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/mute_instance.test.ts index 83bf57f5259a3..a00c75663c5f0 100644 --- a/x-pack/plugins/alerting/server/routes/mute_instance.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/mute_instance.test.ts @@ -7,13 +7,13 @@ import { muteAlertInstanceRoute } from './mute_instance'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/mute_instance.ts b/x-pack/plugins/alerting/server/routes/legacy/mute_instance.ts similarity index 78% rename from x-pack/plugins/alerting/server/routes/mute_instance.ts rename to x-pack/plugins/alerting/server/routes/legacy/mute_instance.ts index ab7749178f6cf..1f38294729619 100644 --- a/x-pack/plugins/alerting/server/routes/mute_instance.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/mute_instance.ts @@ -6,13 +6,13 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { renameKeys } from './lib/rename_keys'; -import { MuteOptions } from '../alerts_client'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { renameKeys } from './../lib/rename_keys'; +import { MuteOptions } from '../../alerts_client'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ alert_id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/unmute_all.test.ts b/x-pack/plugins/alerting/server/routes/legacy/unmute_all.test.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/unmute_all.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/unmute_all.test.ts index 0c2d3105e581c..8511a8b68a447 100644 --- a/x-pack/plugins/alerting/server/routes/unmute_all.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/unmute_all.test.ts @@ -7,13 +7,13 @@ import { unmuteAllAlertRoute } from './unmute_all'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/unmute_all.ts b/x-pack/plugins/alerting/server/routes/legacy/unmute_all.ts similarity index 79% rename from x-pack/plugins/alerting/server/routes/unmute_all.ts rename to x-pack/plugins/alerting/server/routes/legacy/unmute_all.ts index 2e67884f8a944..b29c04acf7c1a 100644 --- a/x-pack/plugins/alerting/server/routes/unmute_all.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/unmute_all.ts @@ -6,11 +6,11 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/unmute_instance.test.ts b/x-pack/plugins/alerting/server/routes/legacy/unmute_instance.test.ts similarity index 87% rename from x-pack/plugins/alerting/server/routes/unmute_instance.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/unmute_instance.test.ts index eddd00390a7f3..d28868a3c9230 100644 --- a/x-pack/plugins/alerting/server/routes/unmute_instance.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/unmute_instance.test.ts @@ -7,13 +7,13 @@ import { unmuteAlertInstanceRoute } from './unmute_instance'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/unmute_instance.ts b/x-pack/plugins/alerting/server/routes/legacy/unmute_instance.ts similarity index 81% rename from x-pack/plugins/alerting/server/routes/unmute_instance.ts rename to x-pack/plugins/alerting/server/routes/legacy/unmute_instance.ts index d39fc696eef08..461c8904876ab 100644 --- a/x-pack/plugins/alerting/server/routes/unmute_instance.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/unmute_instance.ts @@ -6,11 +6,11 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ alertId: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/update.test.ts b/x-pack/plugins/alerting/server/routes/legacy/update.test.ts similarity index 92% rename from x-pack/plugins/alerting/server/routes/update.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/update.test.ts index 892f1a25844c4..da58d0dc41522 100644 --- a/x-pack/plugins/alerting/server/routes/update.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/update.test.ts @@ -7,15 +7,15 @@ import { updateAlertRoute } from './update'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; -import { AlertNotifyWhenType } from '../../common'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; +import { AlertNotifyWhenType } from '../../../common'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/update.ts b/x-pack/plugins/alerting/server/routes/legacy/update.ts similarity index 85% rename from x-pack/plugins/alerting/server/routes/update.ts rename to x-pack/plugins/alerting/server/routes/legacy/update.ts index 11373e71d14be..4f57c37a6c3e8 100644 --- a/x-pack/plugins/alerting/server/routes/update.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/update.ts @@ -6,13 +6,13 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { validateDurationSchema } from '../lib'; -import { handleDisabledApiKeysError } from './lib/error_handler'; -import { AlertNotifyWhenType, BASE_ALERT_API_PATH, validateNotifyWhenType } from '../../common'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { validateDurationSchema } from '../../lib'; +import { handleDisabledApiKeysError } from './../lib/error_handler'; +import { AlertNotifyWhenType, BASE_ALERT_API_PATH, validateNotifyWhenType } from '../../../common'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/update_api_key.test.ts b/x-pack/plugins/alerting/server/routes/legacy/update_api_key.test.ts similarity index 86% rename from x-pack/plugins/alerting/server/routes/update_api_key.test.ts rename to x-pack/plugins/alerting/server/routes/legacy/update_api_key.test.ts index 0added369fd61..3f556f480f69c 100644 --- a/x-pack/plugins/alerting/server/routes/update_api_key.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/update_api_key.test.ts @@ -7,13 +7,13 @@ import { updateApiKeyRoute } from './update_api_key'; import { httpServiceMock } from 'src/core/server/mocks'; -import { licenseStateMock } from '../lib/license_state.mock'; -import { mockHandlerArguments } from './_mock_handler_arguments'; -import { alertsClientMock } from '../alerts_client.mock'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import { licenseStateMock } from '../../lib/license_state.mock'; +import { mockHandlerArguments } from './../_mock_handler_arguments'; +import { alertsClientMock } from '../../alerts_client.mock'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const alertsClient = alertsClientMock.create(); -jest.mock('../lib/license_api_access.ts', () => ({ +jest.mock('../../lib/license_api_access.ts', () => ({ verifyApiAccess: jest.fn(), })); diff --git a/x-pack/plugins/alerting/server/routes/update_api_key.ts b/x-pack/plugins/alerting/server/routes/legacy/update_api_key.ts similarity index 77% rename from x-pack/plugins/alerting/server/routes/update_api_key.ts rename to x-pack/plugins/alerting/server/routes/legacy/update_api_key.ts index a615ee8a5bbd2..c99dc8656526d 100644 --- a/x-pack/plugins/alerting/server/routes/update_api_key.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/update_api_key.ts @@ -6,12 +6,12 @@ */ import { schema } from '@kbn/config-schema'; -import type { AlertingRouter } from '../types'; -import { ILicenseState } from '../lib/license_state'; -import { verifyApiAccess } from '../lib/license_api_access'; -import { BASE_ALERT_API_PATH } from '../../common'; -import { handleDisabledApiKeysError } from './lib/error_handler'; -import { AlertTypeDisabledError } from '../lib/errors/alert_type_disabled'; +import type { AlertingRouter } from '../../types'; +import { ILicenseState } from '../../lib/license_state'; +import { verifyApiAccess } from '../../lib/license_api_access'; +import { BASE_ALERT_API_PATH } from '../../../common'; +import { handleDisabledApiKeysError } from './../lib/error_handler'; +import { AlertTypeDisabledError } from '../../lib/errors/alert_type_disabled'; const paramSchema = schema.object({ id: schema.string(),