35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import http from './http'
|
|
import type { BatchCommandResponse, Connection, ConnectionCreateRequest, ConnectionStatusResponse } from '../types'
|
|
|
|
export function listConnections() {
|
|
return http.get<Connection[]>('/connections')
|
|
}
|
|
|
|
export function createConnection(payload: ConnectionCreateRequest) {
|
|
return http.post<Connection>('/connections', payload)
|
|
}
|
|
|
|
export function updateConnection(id: number, payload: ConnectionCreateRequest) {
|
|
return http.put<Connection>(`/connections/${id}`, payload)
|
|
}
|
|
|
|
export function deleteConnection(id: number) {
|
|
return http.delete<{ message: string }>(`/connections/${id}`)
|
|
}
|
|
|
|
export function executeBatchCommand(connectionIds: number[], command: string) {
|
|
return http.post<BatchCommandResponse>('/connections/batch-command', { connectionIds, command })
|
|
}
|
|
|
|
export function checkConnectionStatuses(connectionIds: number[]) {
|
|
return http.post<ConnectionStatusResponse>('/connections/status', { connectionIds })
|
|
}
|
|
|
|
export function togglePin(id: number) {
|
|
return http.put<Connection>(`/connections/${id}/pin`)
|
|
}
|
|
|
|
export function quickConnect(host: string, username: string, port: number, password: string) {
|
|
return http.post<{ connection: Connection; credentialToken: string }>('/connections/quick-connect', { host, username, port, password })
|
|
}
|