import { IScopedClusterClient } from 'src/core/server' ; interface GetPermissionsArg { isSecurityEnabled : boolean ; client : IScopedClusterClient ; } export async function getPermissions ( { isSecurityEnabled , client } ) { if ( ! isSecurityEnabled ) { return { hasPermission : true , } ; } try { const { body : response } = await client . asCurrentUser . security . hasPrivileges ( { body : { cluster : [ 'manage' ] , } , } ) ; return { hasPermission : response . cluster . manage , } ; } catch ( error ) { return error . body ; } }