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.
[Stack Monitoring] Convert elasticsearch routes to TypeScript (elasti…
- Loading branch information
1 parent
d4167a7
commit 742a2a2
Showing
40 changed files
with
696 additions
and
295 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/monitoring/common/http_api/elasticsearch/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 * from './post_elasticsearch_ccr'; | ||
export * from './post_elasticsearch_ccr_shard'; | ||
export * from './post_elasticsearch_index_detail'; | ||
export * from './post_elasticsearch_indices'; | ||
export * from './post_elasticsearch_ml_jobs'; | ||
export * from './post_elasticsearch_node_detail'; | ||
export * from './post_elasticsearch_nodes'; | ||
export * from './post_elasticsearch_overview'; |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_ccr.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 * as rt from 'io-ts'; | ||
import { clusterUuidRT, ccsRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchCcrRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
}); | ||
|
||
export const postElasticsearchCcrRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchCcrRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchCcrRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchCcrResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_ccr_shard.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,32 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { clusterUuidRT, ccsRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchCcrShardRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
index: rt.string, | ||
shardId: rt.string, | ||
}); | ||
|
||
export const postElasticsearchCcrShardRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchCcrShardRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchCcrShardRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchCcrShardResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_index_detail.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,32 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { ccsRT, clusterUuidRT, createLiteralValueFromUndefinedRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchIndexDetailRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
id: rt.string, | ||
}); | ||
|
||
export const postElasticsearchIndexDetailRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
is_advanced: rt.union([rt.boolean, createLiteralValueFromUndefinedRT(false)]), | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchIndexDetailRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchIndexDetailRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchIndexDetailResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_indices.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,41 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { | ||
booleanFromStringRT, | ||
ccsRT, | ||
clusterUuidRT, | ||
createLiteralValueFromUndefinedRT, | ||
timeRangeRT, | ||
} from '../shared'; | ||
|
||
export const postElasticsearchIndicesRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
}); | ||
|
||
export const postElasticsearchIndicesRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
is_advanced: rt.union([rt.boolean, createLiteralValueFromUndefinedRT(false)]), | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchIndicesRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchIndicesRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchIndicesRequestQueryRT = rt.type({ | ||
show_system_indices: booleanFromStringRT, | ||
}); | ||
|
||
export const postElasticsearchIndicesResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_ml_jobs.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 * as rt from 'io-ts'; | ||
import { clusterUuidRT, ccsRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchMlJobsRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
}); | ||
|
||
export const postElasticsearchMlJobsRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchMlJobsRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchMlJobsRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchMlJobsResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_node_detail.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 * as rt from 'io-ts'; | ||
import { ccsRT, clusterUuidRT, createLiteralValueFromUndefinedRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchNodeDetailRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
nodeUuid: rt.string, | ||
}); | ||
|
||
export const postElasticsearchNodeDetailRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
showSystemIndices: rt.boolean, // show/hide system indices in shard allocation table | ||
}), | ||
rt.type({ | ||
is_advanced: rt.union([rt.boolean, createLiteralValueFromUndefinedRT(false)]), | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchNodeDetailRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchNodeDetailRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchNodeDetailResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_nodes.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 * as rt from 'io-ts'; | ||
import { clusterUuidRT, ccsRT, timeRangeRT, paginationRT, sortingRT } from '../shared'; | ||
|
||
export const postElasticsearchNodesRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
}); | ||
|
||
export const postElasticsearchNodesRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
queryText: rt.string, | ||
sort: sortingRT, | ||
}), | ||
rt.type({ | ||
timeRange: timeRangeRT, | ||
pagination: paginationRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchNodesRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchNodesRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchNodesResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/monitoring/common/http_api/elasticsearch/post_elasticsearch_overview.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 * as rt from 'io-ts'; | ||
import { clusterUuidRT, ccsRT, timeRangeRT } from '../shared'; | ||
|
||
export const postElasticsearchOverviewRequestParamsRT = rt.type({ | ||
clusterUuid: clusterUuidRT, | ||
}); | ||
|
||
export const postElasticsearchOverviewRequestPayloadRT = rt.intersection([ | ||
rt.partial({ | ||
ccs: ccsRT, | ||
}), | ||
rt.type({ | ||
timeRange: timeRangeRT, | ||
}), | ||
]); | ||
|
||
export type PostElasticsearchOverviewRequestPayload = rt.TypeOf< | ||
typeof postElasticsearchOverviewRequestPayloadRT | ||
>; | ||
|
||
export const postElasticsearchOverviewResponsePayloadRT = rt.type({ | ||
// TODO: add payload entries | ||
}); |
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
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/monitoring/common/http_api/shared/literal_value.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,20 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
|
||
export const createLiteralValueFromUndefinedRT = <LiteralValue extends string | number | boolean>( | ||
literalValue: LiteralValue | ||
) => | ||
rt.undefined.pipe( | ||
new rt.Type<LiteralValue, undefined, unknown>( | ||
'BooleanFromString', | ||
rt.literal(literalValue).is, | ||
(_value, _context) => rt.success(literalValue), | ||
() => undefined | ||
) | ||
); |
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/monitoring/common/http_api/shared/pagination.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 * as rt from 'io-ts'; | ||
|
||
export const paginationRT = rt.type({ | ||
index: rt.number, | ||
size: rt.number, | ||
}); |
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/monitoring/common/http_api/shared/query_string_boolean.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,27 @@ | ||
/* | ||
* 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 { chain } from 'fp-ts/lib/Either'; | ||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import * as rt from 'io-ts'; | ||
|
||
export const booleanFromStringRT = new rt.Type<boolean, string, unknown>( | ||
'BooleanFromString', | ||
rt.boolean.is, | ||
(value, context) => | ||
pipe( | ||
rt.string.validate(value, context), | ||
chain((stringValue) => | ||
stringValue === 'true' | ||
? rt.success(true) | ||
: stringValue === 'false' | ||
? rt.success(false) | ||
: rt.failure(value, context) | ||
) | ||
), | ||
String | ||
); |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/monitoring/common/http_api/shared/sorting.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,18 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
|
||
const sortingDirectionRT = rt.keyof({ | ||
asc: null, | ||
desc: null, | ||
}); | ||
|
||
export const sortingRT = rt.partial({ | ||
field: rt.string, | ||
direction: sortingDirectionRT, | ||
}); |
Oops, something went wrong.