mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-04 03:42:08 +08:00
初始化3.0.0版本
This commit is contained in:
201
km-console/packages/layout-clusters-fe/src/api/index.ts
Executable file
201
km-console/packages/layout-clusters-fe/src/api/index.ts
Executable file
@@ -0,0 +1,201 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
const ksPrefix = '/ks-km/api/v3';
|
||||
const securityPrefix = '/logi-security/api/v1';
|
||||
|
||||
function getApi(path: string) {
|
||||
return `${ksPrefix}${path}`;
|
||||
}
|
||||
|
||||
// 指标类型对应的 type 值
|
||||
export enum MetricType {
|
||||
Topic = 100,
|
||||
Cluster = 101,
|
||||
Group = 102,
|
||||
Broker = 103,
|
||||
Partition = 104,
|
||||
Replication = 105,
|
||||
Controls = 901,
|
||||
}
|
||||
|
||||
const api = {
|
||||
// 登录 & 登出
|
||||
login: `${securityPrefix}/account/login`,
|
||||
logout: `${securityPrefix}/account/logout`,
|
||||
|
||||
// 全局信息
|
||||
getUserInfo: (userId: number) => `${securityPrefix}/user/${userId}`,
|
||||
getPermissionTree: `${securityPrefix}/permission/tree`,
|
||||
getKafkaVersionItems: () => getApi('/kafka-versions-items'),
|
||||
getSupportKafkaVersions: (clusterPhyId: string, type: MetricType) =>
|
||||
getApi(`/clusters/${clusterPhyId}/types/${type}/support-kafka-versions`),
|
||||
|
||||
// 生产、消费客户端测试
|
||||
postClientConsumer: getApi(`/clients/consumer`),
|
||||
postClientProducer: getApi(`/clients/producer`),
|
||||
|
||||
// 集群均衡
|
||||
getBalanceList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-overview`),
|
||||
getBrokersMetaList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/brokers-metadata`),
|
||||
getTopicMetaList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics-metadata`),
|
||||
balanceStrategy: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-strategy`),
|
||||
balancePreview: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-preview`),
|
||||
getBalanceHistory: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-history`),
|
||||
getBalanceForm: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-config`),
|
||||
getBalancePlan: (clusterPhyId: number, jobId: number) => getApi(`/clusters/${clusterPhyId}/balance-plan/${jobId}`),
|
||||
getPlatformConfig: (clusterPhyId: number, groupName: string) =>
|
||||
getApi(`/platform-configs/clusters/${clusterPhyId}/groups/${groupName}/configs`),
|
||||
putPlatformConfig: () => getApi(`/platform-configs`),
|
||||
getCartInfo: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/balance-state`),
|
||||
// 获取topic元信息
|
||||
getTopicsMetaData: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/metadata`),
|
||||
getTopicsMetrics: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topic-metrics`),
|
||||
getConsumerGroup: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/groups-basic`),
|
||||
getTopicMetaData: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics-metadata`),
|
||||
getTopicBrokersList: (clusterPhyId: string, topicName: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/brokers`), // 获取 topic brokers 信息
|
||||
getPartitionMetricInfo: (clusterPhyId: string, topicName: string, brokerId: number, partitionId: number) =>
|
||||
getApi(`/clusters/${clusterPhyId}/brokers/${brokerId}/topics/${topicName}/partitions/${partitionId}/latest-metrics`), // 获取分区详情数据
|
||||
|
||||
// dashbord 接口
|
||||
phyClustersDashbord: getApi(`/physical-clusters/dashboard`),
|
||||
supportKafkaVersion: getApi(`/support-kafka-versions`),
|
||||
phyClusterState: getApi(`/physical-clusters/state`),
|
||||
|
||||
getOperatingStateList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/groups-overview`),
|
||||
// 物理集群接口
|
||||
phyCluster: getApi(`/physical-clusters`),
|
||||
getPhyClusterBasic: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/basic`),
|
||||
getPhyClusterMetrics: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/latest-metrics`),
|
||||
getClusterBasicExit: (clusterPhyName: string) => getApi(`/physical-clusters/${clusterPhyName}/basic-combine-exist`),
|
||||
|
||||
kafkaValidator: getApi(`/utils/kafka-validator`),
|
||||
|
||||
// @see https://api-kylin-xg02.intra.xiaojukeji.com/ks-km/swagger-ui.html#/KS-KafkaHealth-%E7%9B%B8%E5%85%B3%E6%8E%A5%E5%8F%A3(REST)/getHealthCheckConfigUsingGET
|
||||
getClusterHealthyConfigs: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/health-configs`),
|
||||
putPlatformConfigs: getApi(`/platform-configs`),
|
||||
|
||||
getClusterChangeLog: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/change-records`),
|
||||
|
||||
// group详情实时信息
|
||||
getTopicGroupMetric: (params: { clusterId: number; topicName: string; groupName: string }) =>
|
||||
getApi(`/clusters/${params.clusterId}/topics/${params.topicName}/groups/${params.groupName}/metric`),
|
||||
// group详情历史信息
|
||||
getConsumersMetadata: (clusterPhyId: number, groupName: string, topicName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/groups/${groupName}/topics/${topicName}/metadata-combine-exist`),
|
||||
getTopicGroupMetricHistory: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/group-metrics`),
|
||||
getTopicGroupPartitionsHistory: (clusterPhyId: number, groupName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/groups/${groupName}/partitions`),
|
||||
resetGroupOffset: () => getApi('/group-offsets'),
|
||||
|
||||
// topics列表
|
||||
getTopicsList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics-overview`),
|
||||
getReassignmentList: () => getApi(`/reassignment/topics-overview`),
|
||||
getTaskPlanData: () => getApi(`/reassignment/replicas-change-plan`),
|
||||
// 创建topic
|
||||
addTopic: () => getApi(`/topics`),
|
||||
deleteTopic: () => getApi(`/topics`),
|
||||
expandPartitions: () => getApi(`/topics/expand-partitions`),
|
||||
getDefaultTopicConfig: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/config-topics/default`),
|
||||
getTopicState: (clusterPhyId: number, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/state`),
|
||||
getTopicMetadata: (clusterPhyId: number, topicName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/topics/${topicName}/metadata-combine-exist`),
|
||||
|
||||
// 最新的指标值
|
||||
getMetricPointsLatest: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/latest-metrics`),
|
||||
getTopicMetricPointsLatest: (clusterPhyId: number, topicName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/topics/${topicName}/latest-metrics`),
|
||||
// 健康检查指标
|
||||
getMetricPoints: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/metric-points`),
|
||||
// 单个Topic的健康检查指标
|
||||
getTopicMetricPoints: (clusterPhyId: number, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/metric-points`),
|
||||
// Broker列表接口
|
||||
getBrokersList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/brokers-overview`),
|
||||
// Broker列表页健康检查指标
|
||||
getBrokerMetricPoints: (clusterPhyId: number) => getApi(`/physical-clusters/${clusterPhyId}/latest-metrics`),
|
||||
// Controller列表接口 /api/v3/clusters/{clusterPhyId}/controller-history「controller-change-log」
|
||||
getChangeLogList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/controller-history`),
|
||||
getBrokersState: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/brokers-state`), // Broker 基础信息
|
||||
|
||||
// Controller列表接口
|
||||
// getChangeLogList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/controller-change-log`),
|
||||
|
||||
// GroupList 列表接口
|
||||
getGroupACLBindingList: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/group-acl-bindings`),
|
||||
|
||||
/* Topic 详情 ↓↓↓↓↓↓↓↓↓↓*/
|
||||
getTopicPartitionsSummary: (clusterPhyId: string, topicName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/topics/${topicName}/brokers-partitions-summary`),
|
||||
getTopicPartitionsDetail: (clusterPhyId: string, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/partitions`),
|
||||
getTopicMessagesList: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/records`), // Messages列表
|
||||
getTopicMessagesMetadata: (topicName: string, clusterPhyId: number) => getApi(`/clusters//${clusterPhyId}/topics/${topicName}/metadata`), // Messages列表
|
||||
getTopicACLsList: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/acl-Bindings`), // ACLs列表
|
||||
getTopicConfigs: (topicName: string, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/config-topics/${topicName}/configs`), // Configuration列表
|
||||
getTopicEditConfig: () => getApi('/config-topics'),
|
||||
/* Topic 详情 ↑↑↑↑↑↑↑↑↑↑↑*/
|
||||
|
||||
/* Broker 详情 ↓↓↓↓↓↓↓↓↓↓*/
|
||||
getBrokerConfigs: (brokerId: number, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/config-brokers/${brokerId}/configs`), // Configuration列表
|
||||
getBrokerDataLogs: (brokerId: number, clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/brokers/${brokerId}/log-dirs`), // ACLs列表
|
||||
getBrokerMetadata: (brokerId: number | string, clusterPhyId: number | string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/brokers/${brokerId}/metadata-combine-exist`), // Broker元数据
|
||||
getBrokerDetailMetricPoints: (brokerId: number | string, clusterPhyId: number | string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/brokers/${brokerId}/latest-metrics`),
|
||||
getBrokerEditConfig: () => getApi('/config-brokers'),
|
||||
/* Broker 详情 ↑↑↑↑↑↑↑↑↑↑↑*/
|
||||
// 具体资源健康检查详情
|
||||
getResourceHealthDetail: (clusterPhyId: number, dimensionCode: number, resName: string) =>
|
||||
getApi(`/clusters/${clusterPhyId}/dimensions/${dimensionCode}/resources/${resName}/health-detail`),
|
||||
// 列表健康检查详情
|
||||
getResourceListHealthDetail: (clusterPhyId: number) => getApi(`/clusters/${clusterPhyId}/health-detail`),
|
||||
|
||||
// Cluster 单集群详情页
|
||||
getClusterDefaultMetricData: () => getApi('/physical-clusters/metrics-multi-value'),
|
||||
getClusterMetricDataList: () => getApi('/physical-clusters/metrics'),
|
||||
|
||||
// BrokerDashboard & TopicDashboard 相关
|
||||
getDashboardMetadata: (clusterPhyId: string, type: MetricType) =>
|
||||
getApi(`/clusters/${clusterPhyId}/${MetricType[type].toLowerCase()}s-metadata`), // 集群节点信息
|
||||
getDashboardMetricList: (clusterPhyId: string, type: MetricType) => getApi(`/clusters/${clusterPhyId}/types/${type}/user-metric-config`), // 默认选中的指标项
|
||||
getDashboardMetricChartData: (clusterPhyId: string, type: MetricType) =>
|
||||
getApi(`/clusters/${clusterPhyId}/${MetricType[type].toLowerCase()}-metrics`), // 图表数据Z
|
||||
|
||||
// ! Jobs 集群任务相关接口
|
||||
getJobsList: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/jobs-overview`),
|
||||
getJobsState: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/jobs-state`),
|
||||
getJobDetail: (clusterPhyId: string, jobId: any) => getApi(`/clusters/${clusterPhyId}/jobs/${jobId}/detail`),
|
||||
getJobsPlanRebalance: (clusterPhyId: string, jobId: any) => getApi(`/clusters/${clusterPhyId}/balance-plan/${jobId}`),
|
||||
getJobsScheduleRebalance: (clusterPhyId: string, jobId: any) => getApi(`/clusters/${clusterPhyId}/balance-schedule/${jobId}`),
|
||||
getJobsDelete: (clusterPhyId: string, jobId: any) => getApi(`/clusters/${clusterPhyId}/jobs/${jobId}`),
|
||||
getJobTraffic: (clusterPhyId: string, jobId: any, flowLimit: any) => {
|
||||
return getApi(`/clusters/${clusterPhyId}/jobs/${jobId}/traffic/${flowLimit}`);
|
||||
},
|
||||
getJobNodeTraffic: (clusterPhyId: string, jobId: any) => {
|
||||
return getApi(`/clusters/${clusterPhyId}/jobs/${jobId}/node/traffic`);
|
||||
},
|
||||
getJobPartitionDetail: (clusterPhyId: string, jobId: any, topicName: any) => {
|
||||
return getApi(`/clusters/${clusterPhyId}/jobs/${jobId}/${topicName}/partition-detail`);
|
||||
},
|
||||
|
||||
// Security - ACLs
|
||||
getACLs: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/acl-bindings`),
|
||||
addACL: getApi('/kafka-acls/batch'),
|
||||
delACLs: getApi('/kafka-acls'),
|
||||
|
||||
// Security - Users
|
||||
getKafkaUsers: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/kafka-users`),
|
||||
kafkaUser: getApi('/kafka-users'),
|
||||
getKafkaUserToken: (clusterPhyId: string, kafkaUser: string) => getApi(`/clusters/${clusterPhyId}/kafka-users/${kafkaUser}/token`),
|
||||
updateKafkaUserToken: getApi('/kafka-users/token'),
|
||||
|
||||
//迁移任务、扩缩副本任务
|
||||
createTask: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/jobs`),
|
||||
//获取topic原数据信息
|
||||
getOneTopicMetaData: (clusterPhyId: string, topicName: string) => getApi(`/clusters/${clusterPhyId}/topics/${topicName}/metadata`),
|
||||
//获取迁移任务预览
|
||||
getMovePlanTaskData: () => getApi(`/reassignment/replicas-move-plan`),
|
||||
//获取任务详情
|
||||
getJobsTaskData: (clusterPhyId: string, jobId: string | number) => getApi(`/clusters/${clusterPhyId}/jobs/${jobId}/modify-detail`),
|
||||
//编辑任务
|
||||
putJobsTaskData: (clusterPhyId: string) => getApi(`/clusters/${clusterPhyId}/jobs`),
|
||||
};
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user