-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
AlertManagement.ts
75 lines (70 loc) · 2.33 KB
/
AlertManagement.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
export interface MetricImageSchema extends Record<string, unknown> {
id: number;
created_at: string;
filename: string;
file_path: string;
url: string;
url_text: string;
}
export class AlertManagement<C extends boolean = false> extends BaseResource<C> {
allMetricImages<E extends boolean = false, P extends PaginationTypes = 'offset'>(
projectId: string | number,
alertIId: number,
options?: PaginationRequestOptions<P> & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<MetricImageSchema[], C, E, P>> {
return RequestHelper.get<MetricImageSchema[]>()(
this,
endpoint`projects/${projectId}/alert_management_alerts/${alertIId}/metric_images`,
options,
);
}
editMetricImage<E extends boolean = false>(
projectId: string | number,
alertIId: number,
imageId: number,
options?: { url?: string; urlText?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<MetricImageSchema, C, E, void>> {
return RequestHelper.put<MetricImageSchema>()(
this,
endpoint`projects/${projectId}/alert_management_alerts/${alertIId}/metric_images/${imageId}`,
options,
);
}
removeMetricImage<E extends boolean = false>(
projectId: string | number,
alertIId: number,
imageId: number,
options?: Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<void, C, E, void>> {
return RequestHelper.del()(
this,
endpoint`projects/${projectId}/alert_management_alerts/${alertIId}/metric_images/${imageId}`,
options,
);
}
uploadMetricImage<E extends boolean = false>(
projectId: string | number,
alertIId: number,
metricImage: { content: Blob; filename: string },
options?: { url?: string; urlText?: string } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<MetricImageSchema, C, E, void>> {
return RequestHelper.post<MetricImageSchema>()(
this,
endpoint`projects/${projectId}/alert_management_alerts/${alertIId}/metric_images`,
{
isForm: true,
file: [metricImage.content, metricImage.filename],
...options,
},
);
}
}