mirror of
https://github.com/langgenius/dify.git
synced 2026-04-16 02:16:57 +08:00
servise of endpoints
This commit is contained in:
parent
0279bd8c75
commit
b1771194cc
@ -114,3 +114,30 @@ export type Permissions = {
|
||||
canManagement: PermissionType
|
||||
canDebugger: PermissionType
|
||||
}
|
||||
|
||||
// endpoint
|
||||
export type CreateEndpointRequest = {
|
||||
plugin_unique_identifier: string
|
||||
settings: Record<string, any>
|
||||
name: string
|
||||
}
|
||||
export type EndpointOperationResponse = {
|
||||
result: 'success' | 'error'
|
||||
}
|
||||
export type EndpointsRequest = {
|
||||
limit: number
|
||||
page: number
|
||||
plugin_id: string
|
||||
}
|
||||
export type EndpointsResponse = {
|
||||
endpoints: EndpointListItem[]
|
||||
has_more: boolean
|
||||
limit: number
|
||||
total: number
|
||||
page: number
|
||||
}
|
||||
export type UpdateEndpointRequest = {
|
||||
endpoint_id: string
|
||||
settings: Record<string, any>
|
||||
name: string
|
||||
}
|
||||
|
||||
@ -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
Block a user