-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] [Logs UI] Reimplement log source configuration routes in plain …
…HTTP+JSON (#64021) (#64626) Backports the following commits to 7.x: - [Logs UI] Reimplement log source configuration routes in plain HTTP+JSON (#64021)
- Loading branch information
1 parent
9c969e7
commit 4778517
Showing
47 changed files
with
2,340 additions
and
95 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
x-pack/plugins/infra/common/http_api/log_sources/get_log_source_configuration.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,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { badRequestErrorRT, forbiddenErrorRT, routeTimingMetadataRT } from '../shared'; | ||
import { logSourceConfigurationRT } from './log_source_configuration'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLogSourceConfigurationRequestParamsRT = rt.type({ | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
}); | ||
|
||
export type GetLogSourceConfigurationRequestParams = rt.TypeOf< | ||
typeof getLogSourceConfigurationRequestParamsRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
export const getLogSourceConfigurationSuccessResponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: logSourceConfigurationRT, | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogSourceConfigurationSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogSourceConfigurationSuccessResponsePayloadRT | ||
>; | ||
|
||
export const getLogSourceConfigurationErrorResponsePayloadRT = rt.union([ | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type GetLogSourceConfigurationErrorReponsePayload = rt.TypeOf< | ||
typeof getLogSourceConfigurationErrorResponsePayloadRT | ||
>; | ||
|
||
export const getLogSourceConfigurationResponsePayloadRT = rt.union([ | ||
getLogSourceConfigurationSuccessResponsePayloadRT, | ||
getLogSourceConfigurationErrorResponsePayloadRT, | ||
]); | ||
|
||
export type GetLogSourceConfigurationReponsePayload = rt.TypeOf< | ||
typeof getLogSourceConfigurationResponsePayloadRT | ||
>; |
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/infra/common/http_api/log_sources/get_log_source_status.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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { routeTimingMetadataRT } from '../shared'; | ||
import { | ||
getLogSourceConfigurationPath, | ||
LOG_SOURCE_CONFIGURATION_PATH, | ||
} from './log_source_configuration'; | ||
|
||
export const LOG_SOURCE_STATUS_PATH_SUFFIX = 'status'; | ||
export const LOG_SOURCE_STATUS_PATH = `${LOG_SOURCE_CONFIGURATION_PATH}/${LOG_SOURCE_STATUS_PATH_SUFFIX}`; | ||
export const getLogSourceStatusPath = (sourceId: string) => | ||
`${getLogSourceConfigurationPath(sourceId)}/${LOG_SOURCE_STATUS_PATH_SUFFIX}`; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLogSourceStatusRequestParamsRT = rt.type({ | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
}); | ||
|
||
export type GetLogSourceStatusRequestParams = rt.TypeOf<typeof getLogSourceStatusRequestParamsRT>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
const logIndexFieldRT = rt.strict({ | ||
name: rt.string, | ||
type: rt.string, | ||
searchable: rt.boolean, | ||
aggregatable: rt.boolean, | ||
}); | ||
|
||
export type LogIndexField = rt.TypeOf<typeof logIndexFieldRT>; | ||
|
||
const logSourceStatusRT = rt.strict({ | ||
logIndexFields: rt.array(logIndexFieldRT), | ||
logIndexNames: rt.array(rt.string), | ||
}); | ||
|
||
export type LogSourceStatus = rt.TypeOf<typeof logSourceStatusRT>; | ||
|
||
export const getLogSourceStatusSuccessResponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: logSourceStatusRT, | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogSourceStatusSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogSourceStatusSuccessResponsePayloadRT | ||
>; |
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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './get_log_source_configuration'; | ||
export * from './get_log_source_status'; | ||
export * from './log_source_configuration'; | ||
export * from './patch_log_source_configuration'; |
78 changes: 78 additions & 0 deletions
78
x-pack/plugins/infra/common/http_api/log_sources/log_source_configuration.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,78 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
|
||
export const LOG_SOURCE_CONFIGURATION_PATH_PREFIX = '/api/infra/log_source_configurations'; | ||
export const LOG_SOURCE_CONFIGURATION_PATH = `${LOG_SOURCE_CONFIGURATION_PATH_PREFIX}/{sourceId}`; | ||
export const getLogSourceConfigurationPath = (sourceId: string) => | ||
`${LOG_SOURCE_CONFIGURATION_PATH_PREFIX}/${sourceId}`; | ||
|
||
export const logSourceConfigurationOriginRT = rt.keyof({ | ||
fallback: null, | ||
internal: null, | ||
stored: null, | ||
}); | ||
|
||
export type LogSourceConfigurationOrigin = rt.TypeOf<typeof logSourceConfigurationOriginRT>; | ||
|
||
const logSourceFieldsConfigurationRT = rt.strict({ | ||
timestamp: rt.string, | ||
tiebreaker: rt.string, | ||
}); | ||
|
||
const logSourceCommonColumnConfigurationRT = rt.strict({ | ||
id: rt.string, | ||
}); | ||
|
||
const logSourceTimestampColumnConfigurationRT = rt.strict({ | ||
timestampColumn: logSourceCommonColumnConfigurationRT, | ||
}); | ||
|
||
const logSourceMessageColumnConfigurationRT = rt.strict({ | ||
messageColumn: logSourceCommonColumnConfigurationRT, | ||
}); | ||
|
||
const logSourceFieldColumnConfigurationRT = rt.strict({ | ||
fieldColumn: rt.intersection([ | ||
logSourceCommonColumnConfigurationRT, | ||
rt.strict({ | ||
field: rt.string, | ||
}), | ||
]), | ||
}); | ||
|
||
const logSourceColumnConfigurationRT = rt.union([ | ||
logSourceTimestampColumnConfigurationRT, | ||
logSourceMessageColumnConfigurationRT, | ||
logSourceFieldColumnConfigurationRT, | ||
]); | ||
|
||
export const logSourceConfigurationPropertiesRT = rt.strict({ | ||
name: rt.string, | ||
description: rt.string, | ||
logAlias: rt.string, | ||
fields: logSourceFieldsConfigurationRT, | ||
logColumns: rt.array(logSourceColumnConfigurationRT), | ||
}); | ||
|
||
export type LogSourceConfigurationProperties = rt.TypeOf<typeof logSourceConfigurationPropertiesRT>; | ||
|
||
export const logSourceConfigurationRT = rt.exact( | ||
rt.intersection([ | ||
rt.type({ | ||
id: rt.string, | ||
origin: logSourceConfigurationOriginRT, | ||
configuration: logSourceConfigurationPropertiesRT, | ||
}), | ||
rt.partial({ | ||
updatedAt: rt.number, | ||
version: rt.string, | ||
}), | ||
]) | ||
); | ||
|
||
export type LogSourceConfiguration = rt.TypeOf<typeof logSourceConfigurationRT>; |
60 changes: 60 additions & 0 deletions
60
x-pack/plugins/infra/common/http_api/log_sources/patch_log_source_configuration.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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { badRequestErrorRT, forbiddenErrorRT } from '../shared'; | ||
import { getLogSourceConfigurationSuccessResponsePayloadRT } from './get_log_source_configuration'; | ||
import { logSourceConfigurationPropertiesRT } from './log_source_configuration'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const patchLogSourceConfigurationRequestParamsRT = rt.type({ | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
}); | ||
|
||
export type PatchLogSourceConfigurationRequestParams = rt.TypeOf< | ||
typeof patchLogSourceConfigurationRequestParamsRT | ||
>; | ||
|
||
const logSourceConfigurationProperiesPatchRT = rt.partial({ | ||
...logSourceConfigurationPropertiesRT.type.props, | ||
fields: rt.partial(logSourceConfigurationPropertiesRT.type.props.fields.type.props), | ||
}); | ||
|
||
export type LogSourceConfigurationPropertiesPatch = rt.TypeOf< | ||
typeof logSourceConfigurationProperiesPatchRT | ||
>; | ||
|
||
export const patchLogSourceConfigurationRequestBodyRT = rt.type({ | ||
data: logSourceConfigurationProperiesPatchRT, | ||
}); | ||
|
||
export type PatchLogSourceConfigurationRequestBody = rt.TypeOf< | ||
typeof patchLogSourceConfigurationRequestBodyRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
export const patchLogSourceConfigurationSuccessResponsePayloadRT = getLogSourceConfigurationSuccessResponsePayloadRT; | ||
|
||
export type PatchLogSourceConfigurationSuccessResponsePayload = rt.TypeOf< | ||
typeof patchLogSourceConfigurationSuccessResponsePayloadRT | ||
>; | ||
|
||
export const patchLogSourceConfigurationResponsePayloadRT = rt.union([ | ||
patchLogSourceConfigurationSuccessResponsePayloadRT, | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type PatchLogSourceConfigurationReponsePayload = rt.TypeOf< | ||
typeof patchLogSourceConfigurationResponsePayloadRT | ||
>; |
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
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/infra/public/containers/logs/log_source/api/fetch_log_source_configuration.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
getLogSourceConfigurationPath, | ||
getLogSourceConfigurationSuccessResponsePayloadRT, | ||
} from '../../../../../common/http_api/log_sources'; | ||
import { decodeOrThrow } from '../../../../../common/runtime_types'; | ||
import { npStart } from '../../../../legacy_singletons'; | ||
|
||
export const callFetchLogSourceConfigurationAPI = async (sourceId: string) => { | ||
const response = await npStart.http.fetch(getLogSourceConfigurationPath(sourceId), { | ||
method: 'GET', | ||
}); | ||
|
||
return decodeOrThrow(getLogSourceConfigurationSuccessResponsePayloadRT)(response); | ||
}; |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/infra/public/containers/logs/log_source/api/fetch_log_source_status.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
getLogSourceStatusPath, | ||
getLogSourceStatusSuccessResponsePayloadRT, | ||
} from '../../../../../common/http_api/log_sources'; | ||
import { decodeOrThrow } from '../../../../../common/runtime_types'; | ||
import { npStart } from '../../../../legacy_singletons'; | ||
|
||
export const callFetchLogSourceStatusAPI = async (sourceId: string) => { | ||
const response = await npStart.http.fetch(getLogSourceStatusPath(sourceId), { | ||
method: 'GET', | ||
}); | ||
|
||
return decodeOrThrow(getLogSourceStatusSuccessResponsePayloadRT)(response); | ||
}; |
Oops, something went wrong.