初始提交:OCI 面板前端(含 GenAI 网关一期)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { mockCosts, mockTraffic } from './mock'
|
||||
import { mockOn, mocked, request } from './request'
|
||||
import type { CostItem, InstanceTraffic } from '@/types/api'
|
||||
|
||||
export function getInstanceTraffic(
|
||||
cfgId: number,
|
||||
instanceId: string,
|
||||
days = 30,
|
||||
region?: string,
|
||||
): Promise<InstanceTraffic> {
|
||||
if (mockOn) return mocked(mockTraffic, 800)
|
||||
return request(`/oci-configs/${cfgId}/instances/${encodeURIComponent(instanceId)}/traffic`, {
|
||||
query: { days, region },
|
||||
})
|
||||
}
|
||||
|
||||
export interface CostQuery {
|
||||
startTime?: string
|
||||
endTime?: string
|
||||
granularity?: 'DAILY' | 'MONTHLY'
|
||||
queryType?: 'COST' | 'USAGE'
|
||||
groupBy?: 'service' | 'skuName' | 'region' | 'compartmentName'
|
||||
}
|
||||
|
||||
export function getCosts(cfgId: number, query: CostQuery = {}): Promise<CostItem[]> {
|
||||
if (mockOn) return mocked(mockCosts)
|
||||
return request(`/oci-configs/${cfgId}/costs`, { query: { ...query } })
|
||||
}
|
||||
Reference in New Issue
Block a user