This PR introduces a new concept of an _Action Subgroup_ (naming is open for discussion) which can be used by an Alert Type when scheduling actions. An Action Subgroup can be dynamically specified, unlike Action Groups which have to be specified on the AlertType definition. When scheduling actions, and AlertType can specify an _Action Subgroup_ along side the scheduled _Action Group_, which denotes that the alert instance falls into some kind of narrower grouping in the action group.
33 lines
982 B
TypeScript
33 lines
982 B
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 * as t from 'io-ts';
|
|
import { DateFromString } from './date_from_string';
|
|
|
|
const metaSchema = t.partial({
|
|
lastScheduledActions: t.intersection([
|
|
t.partial({
|
|
subgroup: t.string,
|
|
}),
|
|
t.type({
|
|
group: t.string,
|
|
date: DateFromString,
|
|
}),
|
|
]),
|
|
});
|
|
export type AlertInstanceMeta = t.TypeOf<typeof metaSchema>;
|
|
|
|
const stateSchema = t.record(t.string, t.unknown);
|
|
export type AlertInstanceState = t.TypeOf<typeof stateSchema>;
|
|
|
|
const contextSchema = t.record(t.string, t.unknown);
|
|
export type AlertInstanceContext = t.TypeOf<typeof contextSchema>;
|
|
|
|
export const rawAlertInstance = t.partial({
|
|
state: stateSchema,
|
|
meta: metaSchema,
|
|
});
|
|
export type RawAlertInstance = t.TypeOf<typeof rawAlertInstance>;
|