github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/ui/src/models/cluster.ts (about) 1 import { api, ListResponse } from './api' 2 3 const injectedRtkApi = api.injectEndpoints({ 4 endpoints: build => ({ 5 dmapiGetClusterInfo: build.query<{ cluster_id: number }, void>({ 6 query: () => ({ url: `/cluster/info` }), 7 }), 8 dmapiGetClusterMasterList: build.query<ListResponse<ClusterMaster>, void>({ 9 query: () => ({ url: `/cluster/masters` }), 10 providesTags: ['ClusterMaster'], 11 }), 12 dmapiOfflineMasterNode: build.mutation<void, string>({ 13 query: masterName => ({ 14 url: `/cluster/masters/${masterName}`, 15 method: 'DELETE', 16 }), 17 invalidatesTags: ['ClusterMaster'], 18 }), 19 dmapiGetClusterWorkerList: build.query<ListResponse<ClusterWorker>, void>({ 20 query: () => ({ url: `/cluster/workers` }), 21 providesTags: ['ClusterWorker'], 22 }), 23 dmapiOfflineWorkerNode: build.mutation<void, string>({ 24 query: workerName => ({ 25 url: `/cluster/workers/${workerName}`, 26 method: 'DELETE', 27 }), 28 invalidatesTags: ['ClusterWorker'], 29 }), 30 }), 31 }) 32 33 export type ClusterMaster = { 34 name: string 35 alive: boolean 36 leader: boolean 37 addr: string 38 } 39 40 export type ClusterWorker = { 41 name: string 42 addr: string 43 bound_stage: string 44 bound_source_name: string 45 } 46 47 export const { 48 useDmapiGetClusterMasterListQuery, 49 useDmapiGetClusterWorkerListQuery, 50 useDmapiOfflineMasterNodeMutation, 51 useDmapiOfflineWorkerNodeMutation, 52 } = injectedRtkApi