forked from project-koku/koku-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocpReports.ts
71 lines (60 loc) · 1.97 KB
/
ocpReports.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
import { axiosInstance } from 'api';
import type { Report, ReportData, ReportItem, ReportItemValue, ReportMeta, ReportValue } from './report';
import { ReportType } from './report';
export interface OcpReportItem extends ReportItem {
capacity?: ReportValue;
cluster?: string;
clusters?: string[];
limit?: ReportValue;
node?: string;
persistent_volume_claim?: string;
project?: string;
request?: ReportValue;
storage_class?: string;
usage?: ReportValue;
}
export interface GroupByClusterData extends Omit<OcpReportData, 'clusters'> {
service: string;
}
export interface GroupByNodeData extends Omit<OcpReportData, 'nodes'> {
region: string;
}
export interface GroupByProjectData extends Omit<OcpReportData, 'projects'> {
account: string;
}
export interface GroupByPvcData extends Omit<OcpReportData, 'persistentvolumeclaims'> {
// TBD...
}
export interface OcpReportData extends ReportData {
cluster_alias?: string;
clusters?: GroupByClusterData[];
nodes?: GroupByNodeData[];
persistentvolumeclaims?: GroupByPvcData[];
projects?: GroupByProjectData[];
}
export interface OcpReportMeta extends ReportMeta {
total?: {
capacity?: ReportValue;
cost?: ReportItemValue;
infrastructure?: ReportItemValue;
limit?: ReportValue;
request?: ReportValue;
supplementary?: ReportItemValue;
usage?: ReportValue;
};
}
export interface OcpReport extends Report {
meta: OcpReportMeta;
data: OcpReportData[];
}
export const ReportTypePaths: Partial<Record<ReportType, string>> = {
[ReportType.cost]: 'reports/openshift/costs/',
[ReportType.cpu]: 'reports/openshift/compute/',
[ReportType.memory]: 'reports/openshift/memory/',
[ReportType.network]: 'reports/openshift/volumes/', // TBD: Use "network" when API is available
[ReportType.volume]: 'reports/openshift/volumes/',
};
export function runReport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axiosInstance.get<OcpReport>(`${path}?${query}`);
}