github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/ui/src/models/source.ts (about) 1 import { api, ListResponse } from './api' 2 3 const injectedRtkApi = api.injectEndpoints({ 4 endpoints: build => ({ 5 dmapiCreateSource: build.mutation< 6 Source, 7 { source: Source; worker_name?: string } 8 >({ 9 query: queryArg => ({ 10 url: `/sources`, 11 method: 'POST', 12 body: queryArg, 13 }), 14 invalidatesTags: ['Source'], 15 }), 16 dmapiGetSourceList: build.query< 17 ListResponse<Source>, 18 { 19 with_status?: boolean 20 enable_relay?: boolean 21 } 22 >({ 23 query: queryArg => ({ 24 url: `/sources`, 25 params: queryArg, 26 }), 27 providesTags: ['Source'], 28 }), 29 dmapiDeleteSource: build.mutation< 30 void, 31 { 32 sourceName: string 33 force?: boolean 34 } 35 >({ 36 query: queryArg => ({ 37 url: `/sources/${queryArg.sourceName}`, 38 method: 'DELETE', 39 params: { force: queryArg.force }, 40 }), 41 invalidatesTags: ['Source'], 42 }), 43 dmapiGetSource: build.query< 44 Source, 45 { sourceName: string; withStatus?: boolean } 46 >({ 47 query: queryArg => ({ 48 url: `/sources/${queryArg.sourceName}`, 49 params: { with_status: queryArg.withStatus }, 50 }), 51 }), 52 dmapiUpdateSource: build.mutation<Source, { source: Source }>({ 53 query: queryArg => ({ 54 url: `/sources/${queryArg.source.source_name}`, 55 method: 'PUT', 56 body: queryArg, 57 }), 58 invalidatesTags: ['Source'], 59 }), 60 dmapiDisableSource: build.mutation<void, string>({ 61 query: queryArg => ({ 62 url: `/sources/${queryArg}/disable`, 63 method: 'POST', 64 }), 65 invalidatesTags: ['Source'], 66 }), 67 dmapiEnableSource: build.mutation<void, string>({ 68 query: queryArg => ({ 69 url: `/sources/${queryArg}/enable`, 70 method: 'POST', 71 }), 72 invalidatesTags: ['Source'], 73 }), 74 dmapiGetSourceStatus: build.query<ListResponse<SourceStatus>, string>({ 75 query: queryArg => ({ 76 url: `/sources/${queryArg}/status`, 77 }), 78 }), 79 dmapiTransferSource: build.mutation< 80 void, 81 { 82 sourceName: string 83 workerName: string 84 } 85 >({ 86 query: queryArg => ({ 87 url: `/sources/${queryArg.sourceName}/transfer`, 88 method: 'POST', 89 body: { 90 worker_name: queryArg.workerName, 91 }, 92 }), 93 invalidatesTags: ['Source'], 94 }), 95 dmapiGetSourceSchemaList: build.query<string[], { sourceName: string }>({ 96 query: queryArg => ({ 97 url: `/sources/${queryArg.sourceName}/schemas`, 98 }), 99 }), 100 dmapiGetSourceTableList: build.mutation< 101 string[], 102 { sourceName: string; schemaName: string } 103 >({ 104 query: queryArg => ({ 105 url: `/sources/${queryArg.sourceName}/schemas/${queryArg.schemaName}`, 106 }), 107 }), 108 dmapiDisableRelay: build.mutation< 109 void, 110 { 111 name: string 112 payload?: { 113 worker_name_list?: string[] 114 } 115 } 116 >({ 117 query: queryArg => ({ 118 url: `/sources/${queryArg.name}/relay/disable`, 119 method: 'POST', 120 body: queryArg.payload, 121 }), 122 invalidatesTags: ['Source'], 123 }), 124 dmapiEnableRelay: build.mutation< 125 void, 126 { 127 name: string 128 payload?: { 129 relay_binlog_gtid?: string | null 130 relay_binlog_name?: string | null 131 relay_dir?: string | null 132 worker_name_list: string[] 133 } 134 } 135 >({ 136 query: queryArg => ({ 137 url: `/sources/${queryArg.name}/relay/enable`, 138 method: 'POST', 139 body: queryArg.payload, 140 }), 141 invalidatesTags: ['Source'], 142 }), 143 dmapiPurgeRelay: build.mutation< 144 void, 145 { 146 name: string 147 purgeRelayRequest: { 148 relay_binlog_name: string 149 relay_dir?: string | null 150 } 151 } 152 >({ 153 query: queryArg => ({ 154 url: `/sources/${queryArg.name}/relay/purge`, 155 method: 'POST', 156 body: queryArg.purgeRelayRequest, 157 }), 158 }), 159 }), 160 }) 161 162 export type Security = { 163 ssl_ca_content: string 164 ssl_cert_content: string 165 ssl_key_content: string 166 cert_allowed_cn?: string[] 167 } | null 168 169 export type Purge = { 170 interval?: number | null 171 expires?: number | null 172 remain_space?: number | null 173 } 174 175 export type RelayStatus = { 176 master_binlog: string 177 master_binlog_gtid: string 178 relay_dir: string 179 relay_binlog_gtid: string 180 relay_catch_up_master: boolean 181 stage: string 182 } 183 184 export type SourceStatus = { 185 source_name: string 186 worker_name: string 187 relay_status?: RelayStatus 188 error_msg?: string 189 } 190 191 export type RelayConfig = { 192 enable_relay?: boolean 193 relay_binlog_name?: string | null 194 relay_binlog_gtid?: string | null 195 relay_dir?: string | null 196 } 197 198 export type Source = { 199 enable: boolean 200 source_name: string 201 host: string 202 port: number 203 user: string 204 password: string 205 enable_gtid: boolean 206 security?: Security 207 purge?: Purge 208 status_list?: SourceStatus[] 209 relay_config?: RelayConfig 210 flavor: string 211 } 212 213 export const { 214 useDmapiCreateSourceMutation, 215 useDmapiGetSourceListQuery, 216 useDmapiDeleteSourceMutation, 217 useDmapiDisableSourceMutation, 218 useDmapiEnableSourceMutation, 219 useDmapiGetSourceQuery, 220 useDmapiUpdateSourceMutation, 221 useDmapiGetSourceStatusQuery, 222 useDmapiTransferSourceMutation, 223 useDmapiGetSourceSchemaListQuery, 224 useDmapiGetSourceTableListMutation, 225 useDmapiDisableRelayMutation, 226 useDmapiEnableRelayMutation, 227 useDmapiPurgeRelayMutation, 228 } = injectedRtkApi