Skip to content

Commit

Permalink
[HTTP] Make alerting APIs public (elastic#183945)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens authored May 22, 2024
1 parent 295b4db commit f0aef3d
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/disable_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const disableRuleRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}/_disable`,
options: {
access: 'public',
description: `Disable a rule`,
},
validate: {
params: paramSchema,
body: bodySchema,
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/enable_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const enableRuleRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}/_enable`,
options: {
access: 'public',
description: `Enable a rule`,
},
validate: {
params: paramSchema,
},
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const healthRoute = (
router.get(
{
path: `${BASE_ALERTING_API_PATH}/_health`,
options: {
access: 'public',
description: `Get the health of the alerting framework`,
},
validate: false,
},
router.handleLegacyErrors(
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/mute_all_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const muteAllRuleRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}/_mute_all`,
options: {
access: 'public',
description: `Mute all alerts`,
},
validate: {
params: paramSchema,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const createRuleRoute = ({ router, licenseState, usageCounter }: RouteOpt
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id?}`,
options: {
access: 'public',
description: `Create a rule`,
},
validate: {
body: createBodySchemaV1,
params: createParamsSchemaV1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const deleteRuleRoute = (
router.delete(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}`,
options: {
access: 'public',
description: `Delete a rule`,
},
validate: {
params: deleteRuleRequestParamsSchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const buildFindRulesRoute = ({
router.get(
{
path,
options: {
access: 'public',
description: `Get rules`,
},
validate: {
query: findRulesRequestQuerySchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { IRouter } from '@kbn/core/server';
import { IRouter, RouteConfigOptions, RouteMethod } from '@kbn/core/server';
import { ILicenseState } from '../../../../lib';
import { verifyAccessAndContext } from '../../../lib';
import type { RuleParamsV1 } from '../../../../../common/routes/rule/response';
Expand All @@ -28,16 +28,19 @@ interface BuildGetRulesRouteParams {
path: string;
router: IRouter<AlertingRequestHandlerContext>;
excludeFromPublicApi?: boolean;
options?: RouteConfigOptions<RouteMethod>;
}
const buildGetRuleRoute = ({
licenseState,
path,
router,
excludeFromPublicApi = false,
options,
}: BuildGetRulesRouteParams) => {
router.get(
{
path,
options,
validate: {
params: getRuleRequestParamsSchemaV1,
},
Expand Down Expand Up @@ -73,6 +76,10 @@ export const getRuleRoute = (
licenseState,
path: `${BASE_ALERTING_API_PATH}/rule/{id}`,
router,
options: {
access: 'public',
description: `Get rule details`,
},
});

export const getInternalRuleRoute = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const muteAlertRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{rule_id}/alert/{alert_id}/_mute`,
options: {
access: 'public',
description: `Mute an alert`,
},
validate: {
params: muteAlertParamsSchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const updateRuleRoute = (
router.put(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}`,
options: {
access: 'public',
description: `Update a rule`,
},
validate: {
body: updateBodySchemaV1,
params: updateParamsSchemaV1,
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/rule_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const ruleTypesRoute = (
router.get(
{
path: `${BASE_ALERTING_API_PATH}/rule_types`,
options: {
access: 'public',
description: `Get rule types`,
},
validate: {},
},
router.handleLegacyErrors(
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/unmute_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const unmuteAlertRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{rule_id}/alert/{alert_id}/_unmute`,
options: {
access: 'public',
description: `Unmute an alert`,
},
validate: {
params: paramSchema,
},
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/unmute_all_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const unmuteAllRuleRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}/_unmute_all`,
options: {
access: 'public',
description: `Unmute all alerts`,
},
validate: {
params: paramSchema,
},
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/alerting/server/routes/update_rule_api_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const updateRuleApiKeyRoute = (
router.post(
{
path: `${BASE_ALERTING_API_PATH}/rule/{id}/_update_api_key`,
options: {
access: 'public',
description: `Update the API key for a rule`,
},
validate: {
params: paramSchema,
},
Expand Down

0 comments on commit f0aef3d

Please sign in to comment.