Skip to content

Commit

Permalink
Move current HTTP APIs to legacy folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Mar 8, 2021
1 parent 96c360b commit d66cf3d
Show file tree
Hide file tree
Showing 38 changed files with 254 additions and 239 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
38 changes: 2 additions & 36 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -267,23 +249,7 @@ export class AlertingPlugin {
// Routes
const router = core.http.createRouter<AlertingRequestHandlerContext>();
// 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<
Expand Down
30 changes: 13 additions & 17 deletions x-pack/plugins/alerting/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AlertingRequestHandlerContext>,
licenseState: ILicenseState,
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup
) {
defineLegacyRoutes(router, licenseState, encryptedSavedObjects);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand Down
Loading

0 comments on commit d66cf3d

Please sign in to comment.