-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-templates.ts
More file actions
28 lines (23 loc) · 1.06 KB
/
Copy pathconfig-templates.ts
File metadata and controls
28 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import client from './client'
import type { ConfigTemplate } from '@/types'
export const configTemplatesApi = {
list: async (): Promise<ConfigTemplate[]> => {
const res = await client.get<{ code: number; data: ConfigTemplate[] }>('/config-templates')
return res.data.data
},
get: async (id: number): Promise<ConfigTemplate> => {
const res = await client.get<{ code: number; data: ConfigTemplate }>(`/config-templates/${id}`)
return res.data.data
},
create: async (data: { name: string; description?: string; content?: string }): Promise<ConfigTemplate> => {
const res = await client.post<{ code: number; data: ConfigTemplate }>('/config-templates', data)
return res.data.data
},
update: async (id: number, data: { name: string; description?: string; content?: string }): Promise<ConfigTemplate> => {
const res = await client.put<{ code: number; data: ConfigTemplate }>(`/config-templates/${id}`, data)
return res.data.data
},
delete: async (id: number): Promise<void> => {
await client.delete(`/config-templates/${id}`)
},
}