| } from '../types' |
| 9 |
| 10 | export const getStatus = () => { |
| 11 | return http.get<StatusResponse>('/api/status') |
| 12 | } |
| 13 |
| 14 | export const getConfig = () => { |
| 15 | return http.get<string>('/api/config') |
| 16 | } |
| 17 |
| 18 | export const putConfig = (content: string) => { |
| 19 | return http.put<void>('/api/config', content) |
| 20 | } |
| 21 |
| 22 | export const reloadConfig = () => { |
| 23 | return http.get<void>('/api/reload') |
| 24 | } |
| 25 |
| 26 | // Config lookup API (any source) |
| 27 | export const getProxyConfig = (name: string) => { |
| 28 | return http.get<ProxyDefinition>( |
| 29 | `/api/proxy/${encodeURIComponent(name)}/config`, |
| 30 | ) |
| 31 | } |
| 32 |
| 33 | export const getVisitorConfig = (name: string) => { |
| 34 | return http.get<VisitorDefinition>( |
| 35 | `/api/visitor/${encodeURIComponent(name)}/config`, |
| 36 | ) |
| 37 | } |
| 38 |
| 39 | // Store API - Proxies |
| 40 | export const listStoreProxies = () => { |
| 41 | return http.get<ProxyListResp>('/api/store/proxies') |
| 42 | } |
| 43 |
| 44 | export const getStoreProxy = (name: string) => { |
| 45 | return http.get<ProxyDefinition>( |
| 46 | `/api/store/proxies/${encodeURIComponent(name)}`, |
| 47 | ) |
| 48 | } |
| 49 |
| 50 | export const createStoreProxy = (config: ProxyDefinition) => { |
| 51 | return http.post<ProxyDefinition>('/api/store/proxies', config) |
| 52 | } |
| 53 |
| 54 | export const updateStoreProxy = (name: string, config: ProxyDefinition) => { |
| 55 | return http.put<ProxyDefinition>( |
| 56 | `/api/store/proxies/${encodeURIComponent(name)}`, |
| 57 | config, |
| 58 | ) |
| 59 | } |
| 60 |
| 61 | export const deleteStoreProxy = (name: string) => { |
| 62 | return http.delete<void>(`/api/store/proxies/${encodeURIComponent(name)}`) |
| 63 | } |
| 64 |
| 65 | // Store API - Visitors |
| 66 | export const listStoreVisitors = () => { |
| 67 | return http.get<VisitorListResp>('/api/store/visitors') |
| 68 | } |
| 69 |
| 70 | export const getStoreVisitor = (name: string) => { |
| 71 | return http.get<VisitorDefinition>( |
| 72 | `/api/store/visitors/${encodeURIComponent(name)}`, |
| 73 | ) |
| 74 | } |
| 75 |
| 76 | export const createStoreVisitor = (config: VisitorDefinition) => { |
| 77 | return http.post<VisitorDefinition>('/api/store/visitors', config) |
| 78 | } |
| 79 |
| 80 | export const updateStoreVisitor = ( |
| 81 | name: string, |
| 82 | config: VisitorDefinition, |
| 83 | ) => { |
| 84 | return http.put<VisitorDefinition>( |
| 85 | `/api/store/visitors/${encodeURIComponent(name)}`, |
| 86 | config, |
| 87 | ) |
| 88 | } |
| 89 |
| 90 | export const deleteStoreVisitor = (name: string) => { |
| 91 | return http.delete<void>(`/api/store/visitors/${encodeURIComponent(name)}`) |
| 92 | } |