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 Internal and Public Find Rules Route (e…
…lastic#180654) ## Summary Issue: elastic#180551 Parent Issue: elastic#157883 Versions the internal and public find API routes. Adds Input validation as well. ### 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
Showing
32 changed files
with
587 additions
and
194 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/alerting/common/routes/rule/apis/find/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 { findRulesRequestQuerySchema } from './schemas/latest'; | ||
export type { FindRulesRequestQuery, FindRulesResponse } from './types/latest'; | ||
|
||
export { findRulesRequestQuerySchema as findRulesRequestQuerySchemaV1 } from './schemas/v1'; | ||
export type { | ||
FindRulesRequestQuery as FindRulesRequestQueryV1, | ||
FindRulesResponse as FindRulesResponseV1, | ||
} from './types/latest'; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/alerting/common/routes/rule/apis/find/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'; |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/alerting/common/routes/rule/apis/find/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,33 @@ | ||
/* | ||
* 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 findRulesRequestQuerySchema = schema.object({ | ||
per_page: schema.number({ defaultValue: 10, min: 0 }), | ||
page: schema.number({ defaultValue: 1, min: 1 }), | ||
search: schema.maybe(schema.string()), | ||
default_search_operator: schema.oneOf([schema.literal('OR'), schema.literal('AND')], { | ||
defaultValue: 'OR', | ||
}), | ||
search_fields: schema.maybe(schema.oneOf([schema.arrayOf(schema.string()), schema.string()])), | ||
sort_field: schema.maybe(schema.string()), | ||
sort_order: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), | ||
has_reference: schema.maybe( | ||
// use nullable as maybe is currently broken | ||
// in config-schema | ||
schema.nullable( | ||
schema.object({ | ||
type: schema.string(), | ||
id: schema.string(), | ||
}) | ||
) | ||
), | ||
fields: schema.maybe(schema.arrayOf(schema.string())), | ||
filter: schema.maybe(schema.string()), | ||
filter_consumers: schema.maybe(schema.arrayOf(schema.string())), | ||
}); |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/alerting/common/routes/rule/apis/find/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'; |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/alerting/common/routes/rule/apis/find/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,21 @@ | ||
/* | ||
* 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 { findRulesRequestQuerySchemaV1 } from '..'; | ||
|
||
export type FindRulesRequestQuery = TypeOf<typeof findRulesRequestQuerySchemaV1>; | ||
|
||
export interface FindRulesResponse<Params extends RuleParamsV1 = never> { | ||
body: { | ||
page: number; | ||
per_page: number; | ||
total: number; | ||
data: Array<Partial<RuleResponseV1<Params>>>; | ||
}; | ||
} |
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
Oops, something went wrong.