mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ResponseOps][Rules] OAS schema registration for newly versioned Rule APIs (#189153)
## Summary Issue: https://github.com/elastic/kibana/issues/187574 This PR updates `request` and `response` schemas below for rule APIs to generate OAS documentation: - `POST /api/alerting/rule/{id?}/_enable` - `POST /api/alerting/rule/{id?}/_disable` - `POST /api/alerting/rule/{id?}/_update_api_key` ### How to test 1. Start ES 2. Add `server.oas.enabled: true` to `kibana.dev.yml` 3. Start Kibana `yarn start --no-base-path` 4. `curl -s -u elastic:changeme http://localhost:5601/api/oas\?pathStartsWith\=/api/alerting/rule/ | jq` 5. Look for `_enable`, `_disable` and `_update_api_key` in the resulting JSON
This commit is contained in:
parent
dd9e94d189
commit
64b45e0884
8 changed files with 50 additions and 10 deletions
|
@ -10,11 +10,22 @@ import { schema } from '@kbn/config-schema';
|
|||
export const disableRuleRequestBodySchema = schema.nullable(
|
||||
schema.maybe(
|
||||
schema.object({
|
||||
untrack: schema.maybe(schema.boolean({ defaultValue: false })),
|
||||
untrack: schema.maybe(
|
||||
schema.boolean({
|
||||
defaultValue: false,
|
||||
meta: {
|
||||
description: "Defines whether this rule's alerts should be untracked.",
|
||||
},
|
||||
})
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
export const disableRuleRequestParamsSchema = schema.object({
|
||||
id: schema.string(),
|
||||
id: schema.string({
|
||||
meta: {
|
||||
description: 'The identifier for the rule.',
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -8,5 +8,9 @@
|
|||
import { schema } from '@kbn/config-schema';
|
||||
|
||||
export const enableRuleRequestParamsSchema = schema.object({
|
||||
id: schema.string(),
|
||||
id: schema.string({
|
||||
meta: {
|
||||
description: 'The identifier for the rule.',
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -8,5 +8,9 @@
|
|||
import { schema } from '@kbn/config-schema';
|
||||
|
||||
export const updateApiKeyParamsSchema = schema.object({
|
||||
id: schema.string(),
|
||||
id: schema.string({
|
||||
meta: {
|
||||
description: 'The identifier for the rule.',
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { updateRuleRoute } from './rule/apis/update/update_rule_route';
|
|||
import { deleteRuleRoute } from './rule/apis/delete/delete_rule_route';
|
||||
import { aggregateRulesRoute } from './rule/apis/aggregate/aggregate_rules_route';
|
||||
import { disableRuleRoute } from './rule/apis/disable/disable_rule_route';
|
||||
import { enableRuleRoute } from './rule/apis/enable/enable_rule';
|
||||
import { enableRuleRoute } from './rule/apis/enable/enable_rule_route';
|
||||
import { findRulesRoute, findInternalRulesRoute } from './rule/apis/find/find_rules_route';
|
||||
import { getRuleAlertSummaryRoute } from './get_rule_alert_summary';
|
||||
import { getRuleExecutionLogRoute } from './get_rule_execution_log';
|
||||
|
|
|
@ -28,8 +28,15 @@ export const disableRuleRoute = (
|
|||
summary: 'Disable a rule',
|
||||
},
|
||||
validate: {
|
||||
params: disableRuleRequestParamsSchemaV1,
|
||||
body: disableRuleRequestBodySchemaV1,
|
||||
request: {
|
||||
params: disableRuleRequestParamsSchemaV1,
|
||||
body: disableRuleRequestBodySchemaV1,
|
||||
},
|
||||
response: {
|
||||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { enableRuleRoute } from './enable_rule';
|
||||
import { enableRuleRoute } from './enable_rule_route';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../../_mock_handler_arguments';
|
|
@ -27,7 +27,14 @@ export const enableRuleRoute = (
|
|||
summary: 'Enable a rule',
|
||||
},
|
||||
validate: {
|
||||
params: enableRuleRequestParamsSchemaV1,
|
||||
request: {
|
||||
params: enableRuleRequestParamsSchemaV1,
|
||||
},
|
||||
response: {
|
||||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(
|
|
@ -26,7 +26,14 @@ export const updateRuleApiKeyRoute = (
|
|||
summary: 'Update the API key for a rule',
|
||||
},
|
||||
validate: {
|
||||
params: updateApiKeyParamsSchemaV1,
|
||||
request: {
|
||||
params: updateApiKeyParamsSchemaV1,
|
||||
},
|
||||
response: {
|
||||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue