forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RAM][HTTP versioning] Version Bulk Enable Route (elastic#179778)
## Summary Parent Issue: elastic#157883 Issue: elastic#179669 Versions the `PATCH /internal/alerting/rules/_bulk_enable` endpoint with added input and output validation. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
a1ada76
commit 4b4c573
Showing
23 changed files
with
604 additions
and
141 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/alerting/common/routes/rule/apis/bulk_enable/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { bulkEnableBodySchema } from './schemas/latest'; | ||
export type { BulkEnableRulesRequestBody, BulkEnableRulesResponse } from './types/latest'; | ||
|
||
export { bulkEnableBodySchema as bulkEnableBodySchemaV1 } from './schemas/v1'; | ||
export type { | ||
BulkEnableRulesRequestBody as BulkEnableRulesRequestBodyV1, | ||
BulkEnableRulesResponse as BulkEnableRulesResponseV1, | ||
} from './types/v1'; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/alerting/common/routes/rule/apis/bulk_enable/schemas/latest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './v1'; |
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/alerting/common/routes/rule/apis/bulk_enable/schemas/v1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
|
||
export const bulkEnableBodySchema = schema.object({ | ||
filter: schema.maybe(schema.string()), | ||
ids: schema.maybe(schema.arrayOf(schema.string(), { minSize: 1, maxSize: 1000 })), | ||
}); |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/alerting/common/routes/rule/apis/bulk_enable/types/latest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './v1'; |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/alerting/common/routes/rule/apis/bulk_enable/types/v1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { TypeOf } from '@kbn/config-schema'; | ||
import { RuleParamsV1, RuleResponseV1 } from '../../../response'; | ||
import { bulkEnableBodySchemaV1 } from '..'; | ||
|
||
export type BulkEnableRulesRequestBody = TypeOf<typeof bulkEnableBodySchemaV1>; | ||
|
||
interface BulkEnableOperationError { | ||
message: string; | ||
status?: number; | ||
rule: { | ||
id: string; | ||
name: string; | ||
}; | ||
} | ||
|
||
export interface BulkEnableRulesResponse<Params extends RuleParamsV1 = never> { | ||
body: { | ||
rules: Array<RuleResponseV1<Params>>; | ||
errors: BulkEnableOperationError[]; | ||
total: number; | ||
task_ids_failed_to_be_enabled: string[]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
x-pack/plugins/alerting/server/application/rule/methods/bulk_enable/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export type { BulkEnableRulesParams, BulkEnableRulesError, BulkEnableRulesResult } from './types'; | ||
|
||
export { bulkEnableRules } from './bulk_enable_rules'; |
13 changes: 13 additions & 0 deletions
13
...alerting/server/application/rule/methods/bulk_enable/schemas/bulk_enable_rules_schemas.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
|
||
export const bulkEnableRulesParamsSchema = schema.object({ | ||
filter: schema.maybe(schema.string()), | ||
ids: schema.maybe(schema.arrayOf(schema.string(), { minSize: 1, maxSize: 1000 })), | ||
}); |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/alerting/server/application/rule/methods/bulk_enable/schemas/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './bulk_enable_rules_schemas'; |
31 changes: 31 additions & 0 deletions
31
...ins/alerting/server/application/rule/methods/bulk_enable/types/bulk_enable_rules_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { RuleParams } from '../../../types/rule'; | ||
import { SanitizedRule } from '../../../../../types'; | ||
|
||
export interface BulkEnableRulesParams { | ||
filter?: string; | ||
ids?: string[]; | ||
} | ||
|
||
export interface BulkEnableRulesError { | ||
message: string; | ||
status?: number; | ||
rule: { | ||
id: string; | ||
name: string; | ||
}; | ||
} | ||
|
||
// TODO (http-versioning): This should be of type Rule, change this when all rule types are fixed | ||
export interface BulkEnableRulesResult<Params extends RuleParams> { | ||
rules: Array<SanitizedRule<Params>>; | ||
errors: BulkEnableRulesError[]; | ||
total: number; | ||
taskIdsFailedToBeEnabled: string[]; | ||
} |
Oops, something went wrong.