mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Response Ops][Rules] OAS Ready Rule API (#196150)](https://github.com/elastic/kibana/pull/196150) <!--- Backport version: 8.9.8 --> ### 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-15T12:50:35Z","message":"[Response Ops][Rules] OAS Ready Rule API (#196150)\n\n## Summary\r\n\r\nLinked to https://github.com/elastic/kibana/issues/195182\r\n\r\n### muteAll \r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](8545b9ccfb/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts (L28)
)\r\n- request schema already with description\r\n[here](8545b9ccfb/x-pack/plugins/alerting/common/routes/rule/apis/mute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### unmuteAll\r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts (L25)
)\r\n- params schema already with description\r\n[here](563910b672/x-pack/plugins/alerting/common/routes/rule/apis/unmute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### rule types\r\n\r\n- added 40x error code to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts (L23)
)\r\n- no request schema\r\n- added response schema descriptions\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"611082ab3178efcc0cd6a9e073c409e4969aa618","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"],"number":196150,"url":"https://github.com/elastic/kibana/pull/196150","mergeCommit":{"message":"[Response Ops][Rules] OAS Ready Rule API (#196150)\n\n## Summary\r\n\r\nLinked to https://github.com/elastic/kibana/issues/195182\r\n\r\n### muteAll \r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](8545b9ccfb/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts (L28)
)\r\n- request schema already with description\r\n[here](8545b9ccfb/x-pack/plugins/alerting/common/routes/rule/apis/mute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### unmuteAll\r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts (L25)
)\r\n- params schema already with description\r\n[here](563910b672/x-pack/plugins/alerting/common/routes/rule/apis/unmute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### rule types\r\n\r\n- added 40x error code to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts (L23)
)\r\n- no request schema\r\n- added response schema descriptions\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"611082ab3178efcc0cd6a9e073c409e4969aa618"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196150","number":196150,"mergeCommit":{"message":"[Response Ops][Rules] OAS Ready Rule API (#196150)\n\n## Summary\r\n\r\nLinked to https://github.com/elastic/kibana/issues/195182\r\n\r\n### muteAll \r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](8545b9ccfb/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts (L28)
)\r\n- request schema already with description\r\n[here](8545b9ccfb/x-pack/plugins/alerting/common/routes/rule/apis/mute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### unmuteAll\r\n\r\n- added 40x error codes to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts (L25)
)\r\n- params schema already with description\r\n[here](563910b672/x-pack/plugins/alerting/common/routes/rule/apis/unmute_all/schemas/v1.ts (L11)
)\r\n- no response schema\r\n\r\n### rule types\r\n\r\n- added 40x error code to response\r\n- `public` access prop already set\r\n[here](563910b672/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts (L23)
)\r\n- no request schema\r\n- added response schema descriptions\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"611082ab3178efcc0cd6a9e073c409e4969aa618"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This commit is contained in:
parent
79f9d05a78
commit
b2ba109781
10 changed files with 276 additions and 42 deletions
|
@ -5077,6 +5077,15 @@
|
|||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
},
|
||||
"400": {
|
||||
"description": "Indicates an invalid schema or parameters."
|
||||
},
|
||||
"403": {
|
||||
"description": "Indicates that this call is forbidden."
|
||||
},
|
||||
"404": {
|
||||
"description": "Indicates a rule with the given ID does not exist."
|
||||
}
|
||||
},
|
||||
"summary": "Mute all alerts",
|
||||
|
@ -5124,6 +5133,15 @@
|
|||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
},
|
||||
"400": {
|
||||
"description": "Indicates an invalid schema or parameters."
|
||||
},
|
||||
"403": {
|
||||
"description": "Indicates that this call is forbidden."
|
||||
},
|
||||
"404": {
|
||||
"description": "Indicates a rule with the given ID does not exist."
|
||||
}
|
||||
},
|
||||
"summary": "Unmute all alerts",
|
||||
|
|
|
@ -5077,6 +5077,15 @@
|
|||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
},
|
||||
"400": {
|
||||
"description": "Indicates an invalid schema or parameters."
|
||||
},
|
||||
"403": {
|
||||
"description": "Indicates that this call is forbidden."
|
||||
},
|
||||
"404": {
|
||||
"description": "Indicates a rule with the given ID does not exist."
|
||||
}
|
||||
},
|
||||
"summary": "Mute all alerts",
|
||||
|
@ -5124,6 +5133,15 @@
|
|||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
},
|
||||
"400": {
|
||||
"description": "Indicates an invalid schema or parameters."
|
||||
},
|
||||
"403": {
|
||||
"description": "Indicates that this call is forbidden."
|
||||
},
|
||||
"404": {
|
||||
"description": "Indicates a rule with the given ID does not exist."
|
||||
}
|
||||
},
|
||||
"summary": "Unmute all alerts",
|
||||
|
|
|
@ -4218,6 +4218,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Mute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
@ -4249,6 +4255,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Unmute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
|
|
@ -4218,6 +4218,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Mute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
@ -4249,6 +4255,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Unmute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
|
|
@ -4598,6 +4598,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Mute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
@ -4629,6 +4635,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Unmute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
|
|
@ -4598,6 +4598,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Mute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
@ -4629,6 +4635,12 @@ paths:
|
|||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
'400':
|
||||
description: Indicates an invalid schema or parameters.
|
||||
'403':
|
||||
description: Indicates that this call is forbidden.
|
||||
'404':
|
||||
description: Indicates a rule with the given ID does not exist.
|
||||
summary: Unmute all alerts
|
||||
tags:
|
||||
- alerting
|
||||
|
|
|
@ -13,58 +13,176 @@ const actionVariableSchema = schema.object({
|
|||
usesPublicBaseUrl: schema.maybe(schema.boolean()),
|
||||
});
|
||||
|
||||
const actionGroupSchema = schema.object({
|
||||
id: schema.string(),
|
||||
name: schema.string(),
|
||||
});
|
||||
const actionGroupSchema = schema.object(
|
||||
{
|
||||
id: schema.string(),
|
||||
name: schema.string(),
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
description:
|
||||
'An action group to use when an alert goes from an active state to an inactive one.',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export const typesRulesResponseBodySchema = schema.arrayOf(
|
||||
schema.object({
|
||||
action_groups: schema.maybe(schema.arrayOf(actionGroupSchema)),
|
||||
action_variables: schema.maybe(
|
||||
schema.object({
|
||||
context: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
state: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
params: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
action_groups: schema.maybe(
|
||||
schema.arrayOf(actionGroupSchema, {
|
||||
meta: {
|
||||
description:
|
||||
"An explicit list of groups for which the rule type can schedule actions, each with the action group's unique ID and human readable name. Rule actions validation uses this configuration to ensure that groups are valid.",
|
||||
},
|
||||
})
|
||||
),
|
||||
action_variables: schema.maybe(
|
||||
schema.object(
|
||||
{
|
||||
context: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
state: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
params: schema.maybe(schema.arrayOf(actionVariableSchema)),
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
description:
|
||||
'A list of action variables that the rule type makes available via context and state in action parameter templates, and a short human readable description. When you create a rule in Kibana, it uses this information to prompt you for these variables in action parameter editors.',
|
||||
},
|
||||
}
|
||||
)
|
||||
),
|
||||
alerts: schema.maybe(
|
||||
schema.object({
|
||||
context: schema.string(),
|
||||
mappings: schema.maybe(
|
||||
schema.object({
|
||||
dynamic: schema.maybe(schema.oneOf([schema.literal(false), schema.literal('strict')])),
|
||||
fieldMap: schema.recordOf(schema.string(), schema.any()),
|
||||
shouldWrite: schema.maybe(schema.boolean()),
|
||||
useEcs: schema.maybe(schema.boolean()),
|
||||
})
|
||||
),
|
||||
})
|
||||
schema.object(
|
||||
{
|
||||
context: schema.string({
|
||||
meta: {
|
||||
description: 'The namespace for this rule type.',
|
||||
},
|
||||
}),
|
||||
mappings: schema.maybe(
|
||||
schema.object({
|
||||
dynamic: schema.maybe(
|
||||
schema.oneOf([schema.literal(false), schema.literal('strict')], {
|
||||
meta: {
|
||||
description: 'Indicates whether new fields are added dynamically.',
|
||||
},
|
||||
})
|
||||
),
|
||||
fieldMap: schema.recordOf(schema.string(), schema.any(), {
|
||||
meta: {
|
||||
description:
|
||||
'Mapping information for each field supported in alerts as data documents for this rule type. For more information about mapping parameters, refer to the Elasticsearch documentation.',
|
||||
},
|
||||
}),
|
||||
shouldWrite: schema.maybe(
|
||||
schema.boolean({
|
||||
meta: {
|
||||
description: 'Indicates whether the rule should write out alerts as data.',
|
||||
},
|
||||
})
|
||||
),
|
||||
useEcs: schema.maybe(
|
||||
schema.boolean({
|
||||
meta: {
|
||||
description:
|
||||
'Indicates whether to include the ECS component template for the alerts.',
|
||||
},
|
||||
})
|
||||
),
|
||||
})
|
||||
),
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
description: 'Details for writing alerts as data documents for this rule type.',
|
||||
},
|
||||
}
|
||||
)
|
||||
),
|
||||
authorized_consumers: schema.recordOf(
|
||||
schema.string(),
|
||||
schema.object({ read: schema.boolean(), all: schema.boolean() })
|
||||
schema.object({ read: schema.boolean(), all: schema.boolean() }),
|
||||
{
|
||||
meta: {
|
||||
description: 'The list of the plugins IDs that have access to the rule type.',
|
||||
},
|
||||
}
|
||||
),
|
||||
category: schema.string(),
|
||||
default_action_group_id: schema.string(),
|
||||
category: schema.string({
|
||||
meta: {
|
||||
description:
|
||||
'The rule category, which is used by features such as category-specific maintenance windows.',
|
||||
},
|
||||
}),
|
||||
default_action_group_id: schema.string({
|
||||
meta: {
|
||||
description: 'The default identifier for the rule type group.',
|
||||
},
|
||||
}),
|
||||
default_schedule_interval: schema.maybe(schema.string()),
|
||||
does_set_recovery_context: schema.maybe(schema.boolean()),
|
||||
enabled_in_license: schema.boolean(),
|
||||
does_set_recovery_context: schema.maybe(
|
||||
schema.boolean({
|
||||
meta: {
|
||||
description:
|
||||
'Indicates whether the rule passes context variables to its recovery action.',
|
||||
},
|
||||
})
|
||||
),
|
||||
enabled_in_license: schema.boolean({
|
||||
meta: {
|
||||
description:
|
||||
'Indicates whether the rule type is enabled or disabled based on the subscription.',
|
||||
},
|
||||
}),
|
||||
fieldsForAAD: schema.maybe(schema.arrayOf(schema.string())),
|
||||
has_alerts_mappings: schema.boolean(),
|
||||
has_fields_for_a_a_d: schema.boolean(),
|
||||
id: schema.string(),
|
||||
is_exportable: schema.boolean(),
|
||||
minimum_license_required: schema.oneOf([
|
||||
schema.literal('basic'),
|
||||
schema.literal('gold'),
|
||||
schema.literal('platinum'),
|
||||
schema.literal('standard'),
|
||||
schema.literal('enterprise'),
|
||||
schema.literal('trial'),
|
||||
]),
|
||||
name: schema.string(),
|
||||
producer: schema.string(),
|
||||
has_alerts_mappings: schema.boolean({
|
||||
meta: {
|
||||
description: 'Indicates whether the rule type has custom mappings for the alert data.',
|
||||
},
|
||||
}),
|
||||
has_fields_for_a_a_d: schema.boolean({
|
||||
meta: {
|
||||
description:
|
||||
'Indicates whether the rule type has fields for alert as data for the alert data. ',
|
||||
},
|
||||
}),
|
||||
id: schema.string({
|
||||
meta: {
|
||||
description: 'The unique identifier for the rule type.',
|
||||
},
|
||||
}),
|
||||
is_exportable: schema.boolean({
|
||||
meta: {
|
||||
description:
|
||||
'Indicates whether the rule type is exportable in Stack Management > Saved Objects.',
|
||||
},
|
||||
}),
|
||||
minimum_license_required: schema.oneOf(
|
||||
[
|
||||
schema.literal('basic'),
|
||||
schema.literal('gold'),
|
||||
schema.literal('platinum'),
|
||||
schema.literal('standard'),
|
||||
schema.literal('enterprise'),
|
||||
schema.literal('trial'),
|
||||
],
|
||||
{
|
||||
meta: {
|
||||
description: 'The subscriptions required to use the rule type.',
|
||||
},
|
||||
}
|
||||
),
|
||||
name: schema.string({
|
||||
meta: {
|
||||
description: 'The descriptive name of the rule type.',
|
||||
},
|
||||
}),
|
||||
producer: schema.string({
|
||||
meta: {
|
||||
description: 'An identifier for the application that produces this rule type.',
|
||||
},
|
||||
}),
|
||||
|
||||
recovery_action_group: actionGroupSchema,
|
||||
rule_task_timeout: schema.maybe(schema.string()),
|
||||
})
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
*/
|
||||
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { TypesRulesResponseBodyV1 } from '../../../../../common/routes/rule/apis/list_types';
|
||||
import {
|
||||
TypesRulesResponseBodyV1,
|
||||
typesRulesResponseSchemaV1,
|
||||
} from '../../../../../common/routes/rule/apis/list_types';
|
||||
import { ILicenseState } from '../../../../lib';
|
||||
import { verifyAccessAndContext } from '../../../lib';
|
||||
import { AlertingRequestHandlerContext, BASE_ALERTING_API_PATH } from '../../../../types';
|
||||
|
@ -24,7 +27,18 @@ export const ruleTypesRoute = (
|
|||
summary: `Get the rule types`,
|
||||
tags: ['oas-tag:alerting'],
|
||||
},
|
||||
validate: {},
|
||||
validate: {
|
||||
request: {},
|
||||
response: {
|
||||
200: {
|
||||
body: () => typesRulesResponseSchemaV1,
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
401: {
|
||||
description: 'Authorization information is missing or invalid.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(
|
||||
verifyAccessAndContext(licenseState, async function (context, req, res) {
|
||||
|
|
|
@ -37,6 +37,15 @@ export const muteAllRuleRoute = (
|
|||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
400: {
|
||||
description: 'Indicates an invalid schema or parameters.',
|
||||
},
|
||||
403: {
|
||||
description: 'Indicates that this call is forbidden.',
|
||||
},
|
||||
404: {
|
||||
description: 'Indicates a rule with the given ID does not exist.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -34,6 +34,15 @@ export const unmuteAllRuleRoute = (
|
|||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
400: {
|
||||
description: 'Indicates an invalid schema or parameters.',
|
||||
},
|
||||
403: {
|
||||
description: 'Indicates that this call is forbidden.',
|
||||
},
|
||||
404: {
|
||||
description: 'Indicates a rule with the given ID does not exist.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue