diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 75a8e1e9a0..574b407895 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -114,3 +114,30 @@ export type Permissions = { canManagement: PermissionType canDebugger: PermissionType } + +// endpoint +export type CreateEndpointRequest = { + plugin_unique_identifier: string + settings: Record + 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 + name: string +} diff --git a/web/service/plugins.ts b/web/service/plugins.ts index e69de29bb2..c5eb55c5c9 100644 --- a/web/service/plugins.ts +++ b/web/service/plugins.ts @@ -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 = ({ url, body }) => { + // url = /workspaces/current/endpoints/create + return post(url, { body }) +} + +export const fetchEndpointList: Fetcher = ({ url, params }) => { + // url = /workspaces/current/endpoints/list/plugin?plugin_id=xxx + return get(url, { params }) +} + +export const deleteEndpoint: Fetcher = ({ url, endpointID }) => { + // url = /workspaces/current/endpoints/delete + return del(url, { body: { endpoint_id: endpointID } }) +} + +export const updateEndpoint: Fetcher = ({ url, body }) => { + // url = /workspaces/current/endpoints/update + return post(url, { body }) +} + +export const enableEndpoint: Fetcher = ({ url, endpointID }) => { + // url = /workspaces/current/endpoints/enable + return post(url, { body: { endpoint_id: endpointID } }) +} + +export const disableEndpoint: Fetcher = ({ url, endpointID }) => { + // url = /workspaces/current/endpoints/disable + return post(url, { body: { endpoint_id: endpointID } }) +}