"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerIndicesRoutes = void 0; var _configSchema = require("@kbn/config-schema"); var _fetch_indices = require("../lib/indices/fetch_indices"); /* * 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 registerIndicesRoutes = ({ router, security }) => { router.get({ path: '/internal/serverless_search/indices', validate: { query: _configSchema.schema.object({ from: _configSchema.schema.number({ defaultValue: 0, min: 0 }), search_query: _configSchema.schema.maybe(_configSchema.schema.string()), size: _configSchema.schema.number({ defaultValue: 20, min: 0 }) }) } }, async (context, request, response) => { const client = (await context.core).elasticsearch.client.asCurrentUser; const user = security.authc.getCurrentUser(request); if (!user) { return response.customError({ statusCode: 502, body: 'Could not retrieve current user, security plugin is not ready' }); } const { from, size, search_query: searchQuery } = request.query; const indices = await (0, _fetch_indices.fetchIndices)(client, from, size, searchQuery); return response.ok({ body: { indices }, headers: { 'content-type': 'application/json' } }); }); }; exports.registerIndicesRoutes = registerIndicesRoutes;