Skip to content

Commit

Permalink
Default alerts as data docs for legacy siem notification rule type
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jan 10, 2024
1 parent 92d6d0e commit 94271d8
Show file tree
Hide file tree
Showing 13 changed files with 726 additions and 308 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
} from '../../../../../common/api/detection_engine/signals_migration/mocks';

// eslint-disable-next-line no-restricted-imports
import type { LegacyRuleNotificationAlertType } from '../../rule_actions_legacy';
import type { LegacyRuleNotificationRuleType } from '../../rule_actions_legacy';
import type { RuleAlertType, RuleParams } from '../../rule_schema';
import { getQueryRuleParams } from '../../rule_schema/mocks';

Expand Down Expand Up @@ -520,7 +520,7 @@ export const legacyGetNotificationResult = ({
}: {
id?: string;
ruleId?: string;
} = {}): LegacyRuleNotificationAlertType => ({
} = {}): LegacyRuleNotificationRuleType => ({
id,
name: 'Notification for Rule Test',
tags: [],
Expand Down Expand Up @@ -567,7 +567,7 @@ export const legacyGetNotificationResult = ({
*/
export const legacyGetFindNotificationsResultWithSingleHit = (
ruleId = '123'
): FindHit<LegacyRuleNotificationAlertType> => ({
): FindHit<LegacyRuleNotificationRuleType> => ({
page: 1,
perPage: 1,
total: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { legacyUpdateOrCreateRuleActionsSavedObject } from '../../logic/rule_act
// eslint-disable-next-line no-restricted-imports
import { legacyReadNotifications } from '../../logic/notifications/legacy_read_notifications';
// eslint-disable-next-line no-restricted-imports
import type { LegacyRuleNotificationAlertTypeParams } from '../../logic/notifications/legacy_types';
import type { LegacyRuleNotificationRuleTypeParams } from '../../logic/notifications/legacy_types';
// eslint-disable-next-line no-restricted-imports
import { legacyCreateNotifications } from '../../logic/notifications/legacy_create_notifications';
import { UPDATE_OR_CREATE_LEGACY_ACTIONS } from '../../../../../../common/constants';
Expand Down Expand Up @@ -75,7 +75,7 @@ export const legacyCreateLegacyNotificationRoute = (
ruleAlertId,
});
if (notification != null) {
await rulesClient.update<LegacyRuleNotificationAlertTypeParams>({
await rulesClient.update<LegacyRuleNotificationRuleTypeParams>({
id: notification.id,
data: {
tags: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
export * from './api/register_routes';

// eslint-disable-next-line no-restricted-imports
export { legacyRulesNotificationAlertType } from './logic/notifications/legacy_rules_notification_alert_type';
export { legacyRulesNotificationRuleType } from './logic/notifications/legacy_rules_notification_rule_type';
// eslint-disable-next-line no-restricted-imports
export { legacyIsNotificationAlertExecutor } from './logic/notifications/legacy_types';
export { isLegacyNotificationRuleExecutor } from './logic/notifications/legacy_types';
// eslint-disable-next-line no-restricted-imports
export type {
LegacyRuleNotificationAlertType,
LegacyRuleNotificationAlertTypeParams,
LegacyRuleNotificationRuleType,
LegacyRuleNotificationRuleTypeParams,
} from './logic/notifications/legacy_types';
export type { NotificationRuleTypeParams } from './logic/notifications/schedule_notification_actions';
export { scheduleNotificationActions } from './logic/notifications/schedule_notification_actions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SERVER_APP_ID, LEGACY_NOTIFICATIONS_ID } from '../../../../../../common
// eslint-disable-next-line no-restricted-imports
import type {
CreateNotificationParams,
LegacyRuleNotificationAlertTypeParams,
LegacyRuleNotificationRuleTypeParams,
} from './legacy_types';

/**
Expand All @@ -23,8 +23,8 @@ export const legacyCreateNotifications = async ({
ruleAlertId,
interval,
name,
}: CreateNotificationParams): Promise<SanitizedRule<LegacyRuleNotificationAlertTypeParams>> =>
rulesClient.create<LegacyRuleNotificationAlertTypeParams>({
}: CreateNotificationParams): Promise<SanitizedRule<LegacyRuleNotificationRuleTypeParams>> =>
rulesClient.create<LegacyRuleNotificationRuleTypeParams>({
data: {
name,
tags: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { RuleTypeParams, SanitizedRule } from '@kbn/alerting-plugin/common'
// eslint-disable-next-line no-restricted-imports
import type { LegacyReadNotificationParams } from './legacy_types';
// eslint-disable-next-line no-restricted-imports
import { legacyIsAlertType } from './legacy_types';
import { isLegacyRuleType } from './legacy_types';
// eslint-disable-next-line no-restricted-imports
import { legacyFindNotifications } from './legacy_find_notifications';

Expand All @@ -24,7 +24,7 @@ export const legacyReadNotifications = async ({
if (id != null) {
try {
const notification = await rulesClient.get({ id });
if (legacyIsAlertType(notification)) {
if (isLegacyRuleType(notification)) {
return notification;
} else {
return null;
Expand All @@ -43,10 +43,7 @@ export const legacyReadNotifications = async ({
filter: `alert.attributes.params.ruleAlertId: "${ruleAlertId}"`,
page: 1,
});
if (
notificationFromFind.data.length === 0 ||
!legacyIsAlertType(notificationFromFind.data[0])
) {
if (notificationFromFind.data.length === 0 || !isLegacyRuleType(notificationFromFind.data[0])) {
return null;
} else {
return notificationFromFind.data[0];
Expand Down

This file was deleted.

Loading

0 comments on commit 94271d8

Please sign in to comment.