From b1479f78166935a157d0f734b95b703457e61172 Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:21:26 +0200 Subject: [PATCH 1/6] add 40x codes --- .../server/routes/rule/apis/mute_all/mute_all_rule.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts b/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts index 8ac77973575bb..e9aa0e42a046f 100644 --- a/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts +++ b/x-pack/plugins/alerting/server/routes/rule/apis/mute_all/mute_all_rule.ts @@ -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.', + }, }, }, }, From 1a3fc66599493b8ad1ed5359bbcd849dd3517b33 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:07:16 +0000 Subject: [PATCH 2/6] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --update' --- oas_docs/bundle.json | 9 +++++++++ oas_docs/bundle.serverless.json | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index 8fdffea9bac41..7b459b390d604 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -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", diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 4719fcb479bb5..4c5f85d1e9075 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -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", From 86365a3ab7c1b071ac52b3da022f2de1105a7850 Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:17:55 +0200 Subject: [PATCH 3/6] add 40x codes unmute_all --- .../routes/rule/apis/unmute_all/unmute_all_rule.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts b/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts index f9ab7d8d8d284..8409128da6241 100644 --- a/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts +++ b/x-pack/plugins/alerting/server/routes/rule/apis/unmute_all/unmute_all_rule.ts @@ -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.', + }, }, }, }, From ad0e726c0b5fde09e436b90e353e93a2a153a237 Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:36:59 +0200 Subject: [PATCH 4/6] add rule types response definitions --- .../routes/rule/apis/list_types/schemas/v1.ts | 197 ++++++++++++++---- .../routes/rule/apis/list_types/rule_types.ts | 18 +- 2 files changed, 173 insertions(+), 42 deletions(-) diff --git a/x-pack/plugins/alerting/common/routes/rule/apis/list_types/schemas/v1.ts b/x-pack/plugins/alerting/common/routes/rule/apis/list_types/schemas/v1.ts index bc38ef051ed90..5ea3d9219ad35 100644 --- a/x-pack/plugins/alerting/common/routes/rule/apis/list_types/schemas/v1.ts +++ b/x-pack/plugins/alerting/common/routes/rule/apis/list_types/schemas/v1.ts @@ -13,58 +13,175 @@ 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()), }) diff --git a/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts b/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts index d6f2ffbe9af0c..da9c62ab5f3f2 100644 --- a/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts +++ b/x-pack/plugins/alerting/server/routes/rule/apis/list_types/rule_types.ts @@ -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) { From 8935252674756dd046f22778cc05805cbab0c68a Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:01:04 +0000 Subject: [PATCH 5/6] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --update' --- oas_docs/bundle.json | 9 +++++++++ oas_docs/bundle.serverless.json | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index 27fe3bae8fc65..744763f3da424 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -5133,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", diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 4c5f85d1e9075..b73fa1fc22841 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -5133,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", From 0c0c435bf5d81dce1c42a22d0f040383d359035e Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:53:06 +0000 Subject: [PATCH 6/6] [CI] Auto-commit changed files from 'make api-docs && make api-docs-staging' --- oas_docs/output/kibana.serverless.staging.yaml | 12 ++++++++++++ oas_docs/output/kibana.serverless.yaml | 12 ++++++++++++ oas_docs/output/kibana.staging.yaml | 12 ++++++++++++ oas_docs/output/kibana.yaml | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/oas_docs/output/kibana.serverless.staging.yaml b/oas_docs/output/kibana.serverless.staging.yaml index 9e63182949f25..a4362db15cc7d 100644 --- a/oas_docs/output/kibana.serverless.staging.yaml +++ b/oas_docs/output/kibana.serverless.staging.yaml @@ -4217,6 +4217,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 @@ -4248,6 +4254,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 diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 9e63182949f25..a4362db15cc7d 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -4217,6 +4217,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 @@ -4248,6 +4254,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 diff --git a/oas_docs/output/kibana.staging.yaml b/oas_docs/output/kibana.staging.yaml index f32de75a62b26..16a6a94d34d81 100644 --- a/oas_docs/output/kibana.staging.yaml +++ b/oas_docs/output/kibana.staging.yaml @@ -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 diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index f32de75a62b26..16a6a94d34d81 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -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