Skip to content

Commit

Permalink
add new attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Nov 15, 2022
1 parent 6786b3d commit 5db2642
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion x-pack/plugins/alerting/server/routes/clone_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import { schema } from '@kbn/config-schema';
import { IRouter } from '@kbn/core/server';
import { ILicenseState, RuleTypeDisabledError } from '../lib';
import { verifyAccessAndContext, RewriteResponseCase, handleDisabledApiKeysError } from './lib';
import {
verifyAccessAndContext,
RewriteResponseCase,
handleDisabledApiKeysError,
rewriteRuleLastRun,
} from './lib';
import {
RuleTypeParams,
AlertingRequestHandlerContext,
Expand Down Expand Up @@ -36,6 +41,8 @@ const rewriteBodyRes: RewriteResponseCase<PartialRule<RuleTypeParams>> = ({
executionStatus,
snoozeSchedule,
isSnoozedUntil,
lastRun,
nextRun,
...rest
}) => ({
...rest,
Expand Down Expand Up @@ -70,6 +77,8 @@ const rewriteBodyRes: RewriteResponseCase<PartialRule<RuleTypeParams>> = ({
})),
}
: {}),
...(lastRun ? { last_run: rewriteRuleLastRun(lastRun) } : {}),
...(nextRun ? { next_run: nextRun } : {}),
});

export const cloneRuleRoute = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
mute_all: false,
muted_alert_ids: [],
execution_status: response.body.execution_status,
last_run: {
alerts_count: {
active: 0,
ignored: 0,
new: 0,
recovered: 0,
},
outcome: 'succeeded',
outcome_msg: null,
warning: null,
},
next_run: response.body.next_run,
});
expect(typeof response.body.scheduled_task_id).to.be('string');
expect(Date.parse(response.body.created_at)).to.be.greaterThan(0);
Expand Down

0 comments on commit 5db2642

Please sign in to comment.