Initial commit
This commit is contained in:
39
frontend/src/api/devices.ts
Normal file
39
frontend/src/api/devices.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { apiClient } from './client';
|
||||
import { Device, PingResult } from './types';
|
||||
|
||||
export interface CreateDeviceInput {
|
||||
name: string;
|
||||
ipAddress: string;
|
||||
port?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateDeviceInput {
|
||||
name?: string;
|
||||
ipAddress?: string;
|
||||
port?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export const deviceApi = {
|
||||
getAll: () => apiClient.get<Device[]>('/devices'),
|
||||
|
||||
getById: (id: string) => apiClient.get<Device>(`/devices/${id}`),
|
||||
|
||||
create: (data: CreateDeviceInput) => apiClient.post<Device>('/devices', data),
|
||||
|
||||
update: (id: string, data: UpdateDeviceInput) =>
|
||||
apiClient.put<Device>(`/devices/${id}`, data),
|
||||
|
||||
delete: (id: string) => apiClient.delete(`/devices/${id}`),
|
||||
|
||||
ping: (id: string) => apiClient.post<PingResult>(`/devices/${id}/ping`),
|
||||
|
||||
turnOn: (id: string) => apiClient.post(`/devices/${id}/turn-on`),
|
||||
|
||||
turnOff: (id: string) => apiClient.post(`/devices/${id}/turn-off`),
|
||||
|
||||
turnOnAll: () => apiClient.post('/devices/all/turn-on'),
|
||||
|
||||
turnOffAll: () => apiClient.post('/devices/all/turn-off'),
|
||||
};
|
||||
Reference in New Issue
Block a user