import api from 'teleport/services/api' ; import cfg from 'teleport/config' ; import makeEvent from './makeEvent' ; import { EventQuery , EventResponse } from './types' ; class AuditService { maxFetchLimit = 5000 ; fetchEvents ( clusterId , params ) { const start = params . from . toISOString ( ) ; const end = params . to . toISOString ( ) ; const url = cfg . getClusterEventsUrl ( clusterId , { start , end , limit : this . maxFetchLimit , include : params . filterBy || undefined , startKey : params . startKey || undefined , } ) ; return api . get ( url ) . then ( json => { const events = json . events || [ ] ; return { events : events . map ( makeEvent ) , startKey : json . startKey } ; } ) ; } } export default AuditService ;