Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Response Ops][Alerting] Using alertsClient for legacy siem notification rule types to write default alerts-as-data docs #174553

Merged
merged 8 commits into from
Jan 15, 2024

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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did some alert to rule renaming

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