-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Rules] Version Get Rule Types API #195361
[Response Ops][Rules] Version Get Rule Types API #195361
Conversation
337b487
to
e30a305
Compare
default_action_group_id: schema.string(), | ||
does_set_recovery_context: schema.maybe(schema.boolean()), | ||
enabled_in_license: schema.boolean(), | ||
fields_for_a_a_d: schema.maybe(schema.arrayOf(schema.string())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that in main the field is returned as fieldsForAAD
. I guess that would be a breaking change, should I leave it with snake_case or change it to work as in main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it would be considered a breaking change so we would need to return fieldsForAAD
.
import { TypesRulesResponseBodyV1 } from '../../../../../../../common/routes/rule/apis/list_types'; | ||
|
||
export const transformRuleTypesResponse = ( | ||
ruleTypes: Set<RegistryAlertTypeWithAuth> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked with @JiaweiWu about RegistryAlertTypeWithAuth Ideally it would be moved to be an application type but it's a complete mess. As long as it's not been used anywhere else, we should be fine. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it should be an application type and the rule client returns a more suitable structure. I would say it is out of the scope of this PR.
return { | ||
...(ruleType.actionGroups ? { action_groups: ruleType.actionGroups } : {}), | ||
...(ruleType.actionVariables ? { action_variables: ruleType.actionVariables } : {}), | ||
...(ruleType.alerts ? { alerts: ruleType.alerts } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one throws an error: Property 'alerts' does not exist on type 'RegistryAlertTypeWithAuth'. I'll add it to the type (see x-pack/plugins/alerting/server/rule_type_registry.ts changes), just let me know if you have more info/know a better option
Pinging @elastic/response-ops (Team:ResponseOps) |
/ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It amazes me that this is a public API that returns all this stuff. Maybe we should document only the important ones.
name: ruleType.name, | ||
producer: ruleType.producer, | ||
recovery_action_group: ruleType.recoveryActionGroup, | ||
rule_task_timeout: ruleType.ruleTaskTimeout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: It seems that ruleTaskTimeout
and defaultScheduleInterval
can be undefined. Should we follow the same patter as above (...(ruleType.alerts ? { alerts: ruleType.alerts } : {}),
)?
name: schema.string(), | ||
}); | ||
|
||
export const typesRulesResponseBodySchema = schema.arrayOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the schema is missing default_schedule_interval
.
…356-version-route-rule-types' of github.com:jcger/kibana into issue-187356-version-route-rule-types
does_set_recovery_context: schema.maybe(schema.boolean()), | ||
enabled_in_license: schema.boolean(), | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
fields_for_AAD: schema.maybe(schema.arrayOf(schema.string())), // we cannot introduce breaking changes yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be fieldsForAAD
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you so much for catching this one 😱
…ger/kibana into issue-187356-version-route-rule-types
…ion-route-rule-types
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11330902192 |
💚 Build Succeeded
Metrics [docs]
History
|
## Summary `GET /api/alerting/rule_types` item in elastic#195181 (cherry picked from commit 512a31d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…6175) # Backport This will backport the following commits from `main` to `8.x`: - [[Response Ops][Rules] Version Get Rule Types API (#195361)](#195361) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julian Gernun","email":"17549662+jcger@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-14T15:46:17Z","message":"[Response Ops][Rules] Version Get Rule Types API (#195361)\n\n## Summary\r\n\r\n`GET /api/alerting/rule_types` item in\r\nhttps://github.com//issues/195181","sha":"512a31d7a1e42139c2e1b26e961b2226ace3836d","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Response Ops][Rules] Version Get Rule Types API","number":195361,"url":"https://github.com/elastic/kibana/pull/195361","mergeCommit":{"message":"[Response Ops][Rules] Version Get Rule Types API (#195361)\n\n## Summary\r\n\r\n`GET /api/alerting/rule_types` item in\r\nhttps://github.com//issues/195181","sha":"512a31d7a1e42139c2e1b26e961b2226ace3836d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195361","number":195361,"mergeCommit":{"message":"[Response Ops][Rules] Version Get Rule Types API (#195361)\n\n## Summary\r\n\r\n`GET /api/alerting/rule_types` item in\r\nhttps://github.com//issues/195181","sha":"512a31d7a1e42139c2e1b26e961b2226ace3836d"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julian Gernun <17549662+jcger@users.noreply.github.com>
Summary
GET /api/alerting/rule_types
item in #195181