[Alerting] System action types and helpers#167871
[Alerting] System action types and helpers#167871guskovaue merged 6 commits intoelastic:system_actions_mvpfrom
Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
|
Pinging @elastic/response-ops-cases (Feature:Cases) |
| } | ||
| return { apiKeysEnabled: false }; | ||
| }, | ||
| isSystemAction(actionId: string) { |
There was a problem hiding this comment.
I named it isSystemAction and not isSystemActionConnector because the checks in the alerting plugin will be done upon rule actions.
| isSummaryActionThrottled, | ||
| } from './rule_action_helper'; | ||
| import { ConnectorAdapter } from '../connector_adapters/types'; | ||
| import { isSystemAction } from '../../common/system_actions/is_system_action'; |
There was a problem hiding this comment.
Should we use actions.isSystemActionConnector (exposed by the rule factory as isSystemAction) instead of using that helper function that checks only the type?
|
|
||
| export type NormalizedAlertAction = Omit<RuleAction, 'actionTypeId'>; | ||
| export type NormalizedAlertAction = DistributiveOmit<RuleAction, 'actionTypeId'>; | ||
| export type NormalizedSystemAction = Omit<RuleSystemAction, 'actionTypeId'>; |
There was a problem hiding this comment.
@cnasikas Why in one case you use DistributiveOmit and in another Omit?
There was a problem hiding this comment.
The reason is that the RuleAction is the union RuleDefaultAction | RuleSystemAction. Normal Omit does not work with unions. If you need to remove a property from each item in the union you need to use DistributiveOmit. For RuleSystemAction is not needed because it is not a union.
| @@ -125,7 +125,7 @@ interface AlertsFilterAttributes { | |||
|
|
|||
| export interface RuleActionAttributes { | |||
There was a problem hiding this comment.
Why we did not create here two types(system and default) instead of one?
There was a problem hiding this comment.
Because this type represents what is being saved in ES. The data in ES should not have the action's type so there is not need to distinguish (I don't think it is possible without the type) the two actions.
There was a problem hiding this comment.
Note that we're deprecating getAlertFromRaw in favor of transformRuleDomainToRuleAttributes, so let's make sure these changes are reflected there as well
There was a problem hiding this comment.
I think that analog of old getAlertFromRaw is a new transformRuleAttributesToRuleDomain. I think I've already added the smae type guard there as well: x-pack/plugins/alerting/server/application/rule/transforms/transform_rule_attributes_to_rule_domain.ts line 157.
Isn't what you meant?
There was a problem hiding this comment.
Thanks for the feedback! This PR is the first of many. I modified transformRuleDomainToRuleAttributes in another PR https://github.com/elastic/kibana/pull/167884/files#diff-25071c31329de46443821b36fad591c9a13261fb61990cb1b3747aef429b808eR22. For transformRuleAttributesToRuleDomain in the same PR here https://github.com/elastic/kibana/pull/167884/files#diff-d5aa343d106a834626d085c1fd6e4a083b05af194c5c8a886c93ab316d4919f8R152. To keep the size small I choose to not do all the changes. My initial PR tried to accommodate everything and it got too big. I closed it in favor of smaller PRs that deliberately will not pass the CI and will get merged in a feature branch.
There was a problem hiding this comment.
@cnasikas I did not recognise your intention from the beginning and started to fix all types :-)
Now I see that you made some of this changes in follow up PRs. So I've deleted my commit for this PR.
984b0f8 to
54fd67a
Compare
💔 Build FailedFailed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @cnasikas |
…#167884) ## Summary This PR enables system actions only to the Create Rule API. Other PRs will follow on a subsequent PR. Depends on: #167871 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Julia <iuliia.guskova@elastic.co>
…API (#168226) Summarize your PR. If it involves visual changes include a screenshot or gif. Depends on: #167871, #167884 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Julia Guskova <iuliia.guskova@elastic.co>
In this PR:
isSystemActionin the executor to determine if an action is a system actionisSystemConnectorutility function from the actions plugin to the rules factoryChecklist
Delete any items that are not applicable to this PR.
For maintainers