import { IScopedClusterClient } from 'kibana/server' ; import { LicensingPluginStart } from '../../../licensing/server' ; interface PutLicenseArg { acknowledge : boolean ; client : IScopedClusterClient ; licensing : LicensingPluginStart ; license : { [ key ] : any ; } ; } export async function putLicense ( { acknowledge , client , licensing , license } ) { try { const { body : response } = await client . asCurrentUser . license . post ( { body : license , acknowledge , } ) ; const { acknowledged , license_status : licenseStatus } = response ; if ( acknowledged && licenseStatus === 'valid' ) { await licensing . refresh ( ) ; } return response ; } catch ( error ) { return error . body ; } }