import { schema } from '@kbn/config-schema' ; import { putLicense } from '../../../lib/license' ; import { RouteDependencies } from '../../../types' ; import { addBasePath } from '../../helpers' ; export function registerLicenseRoute ( { router , lib : { handleEsError } , plugins : { licensing } , } ) { router . put ( { path : addBasePath ( '' ) , validate : { query : schema . object ( { acknowledge : schema . string ( ) } ) , body : schema . object ( { license : schema . object ( { } , { unknowns : 'allow' } ) , } ) , } , } , async ( ctx , req , res ) => { const { client } = ctx . core . elasticsearch ; try { return res . ok ( { body : await putLicense ( { acknowledge : Boolean ( req . query . acknowledge ) , client , licensing , license : req . body , } ) , } ) ; } catch ( error ) { return handleEsError ( { error , response : res } ) ; } } ) ; }