servise of endpoints
parent
0279bd8c75
commit
b1771194cc
@ -0,0 +1,39 @@
|
||||
import type { Fetcher } from 'swr'
|
||||
import { del, get, post } from './base'
|
||||
import type {
|
||||
CreateEndpointRequest,
|
||||
EndpointOperationResponse,
|
||||
EndpointsRequest,
|
||||
EndpointsResponse,
|
||||
UpdateEndpointRequest,
|
||||
} from '@/app/components/plugins/types'
|
||||
|
||||
export const createEndpoint: Fetcher<EndpointOperationResponse, { url: string; body: CreateEndpointRequest }> = ({ url, body }) => {
|
||||
// url = /workspaces/current/endpoints/create
|
||||
return post<EndpointOperationResponse>(url, { body })
|
||||
}
|
||||
|
||||
export const fetchEndpointList: Fetcher<EndpointsResponse, { url: string; params?: EndpointsRequest }> = ({ url, params }) => {
|
||||
// url = /workspaces/current/endpoints/list/plugin?plugin_id=xxx
|
||||
return get<EndpointsResponse>(url, { params })
|
||||
}
|
||||
|
||||
export const deleteEndpoint: Fetcher<EndpointOperationResponse, { url: string; endpointID: string }> = ({ url, endpointID }) => {
|
||||
// url = /workspaces/current/endpoints/delete
|
||||
return del<EndpointOperationResponse>(url, { body: { endpoint_id: endpointID } })
|
||||
}
|
||||
|
||||
export const updateEndpoint: Fetcher<EndpointOperationResponse, { url: string; body: UpdateEndpointRequest }> = ({ url, body }) => {
|
||||
// url = /workspaces/current/endpoints/update
|
||||
return post<EndpointOperationResponse>(url, { body })
|
||||
}
|
||||
|
||||
export const enableEndpoint: Fetcher<EndpointOperationResponse, { url: string; endpointID: string }> = ({ url, endpointID }) => {
|
||||
// url = /workspaces/current/endpoints/enable
|
||||
return post<EndpointOperationResponse>(url, { body: { endpoint_id: endpointID } })
|
||||
}
|
||||
|
||||
export const disableEndpoint: Fetcher<EndpointOperationResponse, { url: string; endpointID: string }> = ({ url, endpointID }) => {
|
||||
// url = /workspaces/current/endpoints/disable
|
||||
return post<EndpointOperationResponse>(url, { body: { endpoint_id: endpointID } })
|
||||
}
|
||||
Loading…
Reference in New Issue