import { UsageCounter } from 'src/plugins/usage_collection/server' ; import type { AlertingRouter } from '../../types' ; import { ILicenseState } from '../../lib/license_state' ; import { verifyApiAccess } from '../../lib/license_api_access' ; import { LEGACY_BASE_ALERT_API_PATH } from '../../../common' ; import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage' ; export const listAlertTypesRoute = ( router , licenseState , usageCounter ? ) => { router . get ( { path : `${ LEGACY_BASE_ALERT_API_PATH }/list_alert_types` , validate : { } , } , router . handleLegacyErrors ( async function ( context , req , res ) { verifyApiAccess ( licenseState ) ; if ( ! context . alerting ) { return res . badRequest ( { body : 'RouteHandlerContext is not registered for alerting' } ) ; } trackLegacyRouteUsage ( 'listAlertTypes' , usageCounter ) ; return res . ok ( { body : Array . from ( await context . alerting . getRulesClient ( ) . listAlertTypes ( ) ) , } ) ; } ) ) ; } ;