Skip to content

Commit

Permalink
Add missing error codes and remove error schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Sep 18, 2024
1 parent 3c6121c commit a8d4987
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 43 deletions.
4 changes: 0 additions & 4 deletions x-pack/plugins/alerting/common/routes/rule/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ export type {
RuleExecutionStatusErrorReason as RuleExecutionStatusErrorReasonV1,
RuleExecutionStatusWarningReason as RuleExecutionStatusWarningReasonV1,
} from './constants/v1';

export { forbiddenErrorSchema } from './schemas/latest';

export { forbiddenErrorSchema as forbiddenErrorSchemaV1 } from './schemas/v1';

This file was deleted.

14 changes: 0 additions & 14 deletions x-pack/plugins/alerting/common/routes/rule/common/schemas/v1.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
createBodySchemaV1,
createParamsSchemaV1,
} from '../../../../../common/routes/rule/apis/create';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import { RuleParamsV1, ruleResponseSchemaV1 } from '../../../../../common/routes/rule/response';
import { Rule } from '../../../../application/rule/types';
import { RuleTypeDisabledError } from '../../../../lib';
Expand Down Expand Up @@ -48,12 +47,14 @@ export const createRuleRoute = ({ router, licenseState, usageCounter }: RouteOpt
body: () => ruleResponseSchemaV1,
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
400: {
description: 'Indicates that the requested rule type is not registered.',
409: {
description: 'Indicates that the rule id is already in use.',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const deleteRuleRoute = (
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.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
disableRuleRequestBodySchemaV1,
disableRuleRequestParamsSchemaV1,
} from '../../../../../common/routes/rule/apis/disable';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import { ILicenseState, RuleTypeDisabledError } from '../../../../lib';
import { AlertingRequestHandlerContext, BASE_ALERTING_API_PATH } from '../../../../types';
import { verifyAccessAndContext } from '../../../lib';
Expand All @@ -38,8 +37,10 @@ export const disableRuleRoute = (
204: {
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
EnableRuleRequestParamsV1,
enableRuleRequestParamsSchemaV1,
} from '../../../../../common/routes/rule/apis/enable';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';

export const enableRuleRoute = (
router: IRouter<AlertingRequestHandlerContext>,
licenseState: ILicenseState
Expand All @@ -36,8 +34,10 @@ export const enableRuleRoute = (
204: {
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const buildGetRuleRoute = ({
body: () => ruleResponseSchemaV1,
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.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { transformRequestParamsToApplicationV1 } from './transforms';
import { ILicenseState, RuleTypeDisabledError } from '../../../../lib';
import { verifyAccessAndContext } from '../../../lib';
import { AlertingRequestHandlerContext, BASE_ALERTING_API_PATH } from '../../../../types';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import {
muteAlertParamsSchemaV1,
MuteAlertRequestParamsV1,
Expand All @@ -35,8 +34,10 @@ export const muteAlertRoute = (
204: {
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
UnmuteAlertRequestParamsV1,
unmuteAlertParamsSchemaV1,
} from '../../../../../common/routes/rule/apis/unmute_alert';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import { ILicenseState, RuleTypeDisabledError } from '../../../../lib';
import { AlertingRequestHandlerContext, BASE_ALERTING_API_PATH } from '../../../../types';
import { verifyAccessAndContext } from '../../../lib';
Expand All @@ -36,8 +35,10 @@ export const unmuteAlertRoute = (
204: {
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { IRouter } from '@kbn/core/server';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import type {
UpdateRuleRequestBodyV1,
UpdateRuleRequestParamsV1,
Expand Down Expand Up @@ -47,13 +46,18 @@ export const updateRuleRoute = (
body: () => ruleResponseSchemaV1,
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
description: 'Indicates a rule with the given ID does not exist.',
},
409: {
description: 'Indicates that the rule has already been updated by another user.',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
UpdateApiKeyParamsV1,
updateApiKeyParamsSchemaV1,
} from '../../../../../common/routes/rule/apis/update_api_key';
import { forbiddenErrorSchemaV1 } from '../../../../../common/routes/rule/common';
import { ILicenseState, RuleTypeDisabledError } from '../../../../lib';
import { AlertingRequestHandlerContext, BASE_ALERTING_API_PATH } from '../../../../types';
import { verifyAccessAndContext } from '../../../lib';
Expand All @@ -35,13 +34,18 @@ export const updateRuleApiKeyRoute = (
204: {
description: 'Indicates a successful call.',
},
400: {
description: 'Indicates an invalid schema or parameters.',
},
403: {
body: () => forbiddenErrorSchemaV1,
description: 'Indicates that this call is forbidden.',
},
404: {
description: 'Indicates a rule with the given ID does not exist.',
},
409: {
description: 'Indicates that the rule has already been updated by another user.',
},
},
},
},
Expand Down

0 comments on commit a8d4987

Please sign in to comment.