"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createIndex = void 0; var _securitysolutionEsUtils = require("@kbn/securitysolution-es-utils"); /* * 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. */ const createIndex = async ({ esClient, logger, options }) => { try { const isIndexExist = await esClient.indices.exists({ index: options.index }); if (isIndexExist) { logger.info('${options.index} already exist'); return; } return esClient.indices.create(options); } catch (err) { const error = (0, _securitysolutionEsUtils.transformError)(err); const fullErrorMessage = `Failed to create index: ${options.index}: ${error.message}`; logger.error(fullErrorMessage); throw new Error(fullErrorMessage); } }; exports.createIndex = createIndex;