forked from project-koku/koku-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcostModels.ts
69 lines (59 loc) · 1.69 KB
/
costModels.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
import { axiosInstance } from 'api';
import type { PagedResponse } from './api';
import type { Rate, RateRequest } from './rates';
export interface CostModelProvider {
name: string;
last_processed?: string;
uuid: string;
}
export interface CostModel {
created_timestamp?: Date;
currency?: string;
description: string;
distribution_info?: {
distribution_type?: string;
network_cost?: boolean;
platform_cost?: boolean;
storage_cost?: boolean;
worker_cost?: boolean;
};
markup: { value: string; unit: string };
name: string;
rates: Rate[];
sources?: CostModelProvider[];
source_type: string;
updated_timestamp?: Date;
uuid?: string;
}
export interface CostModelRequest {
currency?: string;
description: string;
distribution_info?: {
distribution_type?: string;
network_cost?: boolean;
platform_cost?: boolean;
storage_cost?: boolean;
worker_cost?: boolean;
};
markup: { value: string; unit: string };
name: string;
rates: RateRequest[];
source_type: string;
source_uuids: string[];
}
export type CostModels = PagedResponse<CostModel>;
export function fetchCostModels(query = '') {
return axiosInstance.get<CostModels>(`cost-models/${query && '?'}${query}`);
}
export function fetchCostModel(uuid: string) {
return axiosInstance.get<CostModels>(`cost-models/${uuid}/`);
}
export function addCostModel(request: CostModelRequest) {
return axiosInstance.post(`cost-models/`, request);
}
export function updateCostModel(uuid: string, request: CostModelRequest) {
return axiosInstance.put(`cost-models/${uuid}/`, request);
}
export function deleteCostModel(uuid: string) {
return axiosInstance.delete(`cost-models/${uuid}/`);
}