import type { ElasticsearchClient } from 'src/core/server' ; import { ILM_POLICY_NAME } from '../../../../common/constants' ; import { reportingIlmPolicy } from './constants' ; /**
 * Responsible for detecting and provisioning the reporting ILM policy.
 *
 * Uses the provided  ElasticsearchClient to scope request privileges.
  export class IlmPolicyManager { constructor ( private readonly client ) { } public static create ( opts ) { return new IlmPolicyManager ( opts . client ) ; } public async doesIlmPolicyExist ( ) { try { await this . client . ilm . getLifecycle ( { name : ILM_POLICY_NAME } ) ; return true ; } catch ( e ) { if ( e . statusCode === 404 ) { return false ; } throw e ; } } /**
     * Create the Reporting ILM policy
     */ public async createIlmPolicy ( ) { await this . client . ilm . putLifecycle ( { name : ILM_POLICY_NAME , body : reportingIlmPolicy , } ) ; } }