Skip to content

Modern Docker Management, Designed for Everyone

825 B
Raw Blame
import type { SearchPaginationSortRequest, Paginated } from '#lib/types/shared.js';
import type { Event, EventSeverityCounts } from '#lib/types/shared.js';
import { transformPaginationParams } from '#lib/utils/tables.js';

import BaseAPIService from './api-service';

class EventService extends BaseAPIService {
	async getEvents(options?: SearchPaginationSortRequest): Promise<Paginated<Event>> {
		const params = transformPaginationParams(options);
		const res = await this.api.get('/events', { params });
		return res.data;
	}

	async getEventStats(): Promise<EventSeverityCounts> {
		const res = await this.api.get('/events/stats');
		return res.data.data;
	}

	async delete(id: string): Promise<void> {
		return this.handleResponse(this.api.delete(`/events/${id}`));
	}
}

export const eventService = new EventService();