start working on the frontend side
This commit is contained in:
86
frontend/src/api/storage.ts
Normal file
86
frontend/src/api/storage.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import apiClient from './client'
|
||||
|
||||
export interface PhysicalDisk {
|
||||
id: string
|
||||
device_path: string
|
||||
vendor?: string
|
||||
model?: string
|
||||
serial_number?: string
|
||||
size_bytes: number
|
||||
sector_size?: number
|
||||
is_ssd: boolean
|
||||
health_status: string
|
||||
is_used: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface VolumeGroup {
|
||||
id: string
|
||||
name: string
|
||||
size_bytes: number
|
||||
free_bytes: number
|
||||
physical_volumes: string[]
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface Repository {
|
||||
id: string
|
||||
name: string
|
||||
description?: string
|
||||
volume_group: string
|
||||
logical_volume: string
|
||||
size_bytes: number
|
||||
used_bytes: number
|
||||
filesystem_type?: string
|
||||
mount_point?: string
|
||||
is_active: boolean
|
||||
warning_threshold_percent: number
|
||||
critical_threshold_percent: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export const storageApi = {
|
||||
listDisks: async (): Promise<PhysicalDisk[]> => {
|
||||
const response = await apiClient.get<PhysicalDisk[]>('/storage/disks')
|
||||
return response.data
|
||||
},
|
||||
|
||||
syncDisks: async (): Promise<{ task_id: string }> => {
|
||||
const response = await apiClient.post<{ task_id: string }>('/storage/disks/sync')
|
||||
return response.data
|
||||
},
|
||||
|
||||
listVolumeGroups: async (): Promise<VolumeGroup[]> => {
|
||||
const response = await apiClient.get<VolumeGroup[]>('/storage/volume-groups')
|
||||
return response.data
|
||||
},
|
||||
|
||||
listRepositories: async (): Promise<Repository[]> => {
|
||||
const response = await apiClient.get<Repository[]>('/storage/repositories')
|
||||
return response.data
|
||||
},
|
||||
|
||||
getRepository: async (id: string): Promise<Repository> => {
|
||||
const response = await apiClient.get<Repository>(`/storage/repositories/${id}`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
createRepository: async (data: {
|
||||
name: string
|
||||
description?: string
|
||||
volume_group: string
|
||||
size_gb: number
|
||||
filesystem_type?: string
|
||||
}): Promise<{ task_id: string }> => {
|
||||
const response = await apiClient.post<{ task_id: string }>('/storage/repositories', data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
deleteRepository: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/storage/repositories/${id}`)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user