import { LegacyAPICaller } from 'opensearch-dashboards/server' ; import { convertOpenSearchError } from './errors' ; import { FieldCapsResponse } from './field_capabilities' ; export interface IndicesAliasResponse { [ index ] : IndexAliasResponse ; } export interface IndexAliasResponse { aliases : { [ aliasName ] : Record < string , any > ; } ; } param { Function } callCluster param { Array < String > | String } indices return { Promise < IndexAliasResponse > } export async function callIndexAliasApi ( callCluster , indices ) { try { return ( await callCluster ( 'indices.getAlias' , { index : indices , ignoreUnavailable : true , allowNoIndices : false , } ) ) as Promise < IndicesAliasResponse > ; } catch ( error ) { throw convertOpenSearchError ( indices , error ) ; } } param { Function } callCluster param { Array < String > | String } indices param { Object } fieldCapsOptions return { Promise < FieldCapsResponse > } export async function callFieldCapsApi ( callCluster , indices , fieldCapsOptions = { allowNoIndices : false } ) { try { return ( await callCluster ( 'fieldCaps' , { index : indices , fields : '*' , ignoreUnavailable : true , ... fieldCapsOptions , } ) ) as FieldCapsResponse ; } catch ( error ) { throw convertOpenSearchError ( indices , error ) ; } }