kibana/x-pack/plugins/infra/server/utils/elasticsearch_runtime_types.ts
Felix Stürmer 1a7095365a
[Logs UI] Allow for missing properties on ES shard failure responses (#96768)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-15 13:28:26 +02:00

41 lines
1 KiB
TypeScript

/*
* 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 shardFailureRT = rt.partial({
index: rt.union([rt.string, rt.null]),
node: rt.union([rt.string, rt.null]),
reason: rt.partial({
reason: rt.union([rt.string, rt.null]),
type: rt.union([rt.string, rt.null]),
}),
shard: rt.number,
});
export type ShardFailure = rt.TypeOf<typeof shardFailureRT>;
export const commonSearchSuccessResponseFieldsRT = rt.type({
_shards: rt.intersection([
rt.type({
total: rt.number,
successful: rt.number,
skipped: rt.number,
failed: rt.number,
}),
rt.partial({
failures: rt.array(shardFailureRT),
}),
]),
timed_out: rt.boolean,
took: rt.number,
});
export const commonHitFieldsRT = rt.type({
_index: rt.string,
_id: rt.string,
});