import {Client} from 'sentry/api'; import type {MetricRule} from 'sentry/views/alerts/rules/metric/types'; import type {Anomaly, Incident} from '../types'; // Use this api for requests that are getting cancelled const uncancellableApi = new Client(); export function fetchAlertRule( orgId: string, ruleId: string, query?: Record ): Promise { return uncancellableApi.requestPromise( `/organizations/${orgId}/alert-rules/${ruleId}/`, {query} ); } export function fetchIncidentsForRule( orgId: string, ruleId: string, start: string, end: string ): Promise { return uncancellableApi.requestPromise(`/organizations/${orgId}/incidents/`, { query: { project: '-1', alertRule: ruleId, includeSnapshots: true, start, end, expand: ['activities', 'seen_by', 'original_alert_rule'], }, }); } export function fetchIncident( api: Client, orgId: string, alertId: string ): Promise { return api.requestPromise(`/organizations/${orgId}/incidents/${alertId}/`); } export function fetchAnomaliesForRule( orgId: string, ruleId: string, start: string, end: string ): Promise { return uncancellableApi.requestPromise( `/organizations/${orgId}/alert-rules/${ruleId}/anomalies/`, { query: { start, end, }, } ); }