|
@@ -1,23 +1,68 @@
|
|
-import * as api from 'redux/api';
|
|
|
|
|
|
+import {
|
|
|
|
+ ApiClustersApi,
|
|
|
|
+ Configuration,
|
|
|
|
+ Cluster,
|
|
|
|
+ Topic,
|
|
|
|
+ TopicFormData,
|
|
|
|
+ TopicConfig,
|
|
|
|
+} from 'generated-sources';
|
|
import {
|
|
import {
|
|
ConsumerGroupID,
|
|
ConsumerGroupID,
|
|
PromiseThunk,
|
|
PromiseThunk,
|
|
- Cluster,
|
|
|
|
ClusterName,
|
|
ClusterName,
|
|
- TopicFormData,
|
|
|
|
|
|
+ BrokerId,
|
|
TopicName,
|
|
TopicName,
|
|
- Topic,
|
|
|
|
TopicMessageQueryParams,
|
|
TopicMessageQueryParams,
|
|
|
|
+ TopicFormFormattedParams,
|
|
|
|
+ TopicFormDataRaw,
|
|
} from 'redux/interfaces';
|
|
} from 'redux/interfaces';
|
|
|
|
|
|
|
|
+import { BASE_PARAMS } from 'lib/constants';
|
|
import * as actions from './actions';
|
|
import * as actions from './actions';
|
|
|
|
|
|
|
|
+const apiClientConf = new Configuration(BASE_PARAMS);
|
|
|
|
+const apiClient = new ApiClustersApi(apiClientConf);
|
|
|
|
+
|
|
|
|
+export const fetchClustersList = (): PromiseThunk<void> => async (dispatch) => {
|
|
|
|
+ dispatch(actions.fetchClusterListAction.request());
|
|
|
|
+ try {
|
|
|
|
+ const clusters: Cluster[] = await apiClient.getClusters();
|
|
|
|
+ dispatch(actions.fetchClusterListAction.success(clusters));
|
|
|
|
+ } catch (e) {
|
|
|
|
+ dispatch(actions.fetchClusterListAction.failure());
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export const fetchClusterStats = (
|
|
|
|
+ clusterName: ClusterName
|
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
|
+ dispatch(actions.fetchClusterStatsAction.request());
|
|
|
|
+ try {
|
|
|
|
+ const payload = await apiClient.getClusterStats({ clusterName });
|
|
|
|
+ dispatch(actions.fetchClusterStatsAction.success(payload));
|
|
|
|
+ } catch (e) {
|
|
|
|
+ dispatch(actions.fetchClusterStatsAction.failure());
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export const fetchClusterMetrics = (
|
|
|
|
+ clusterName: ClusterName
|
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
|
+ dispatch(actions.fetchClusterMetricsAction.request());
|
|
|
|
+ try {
|
|
|
|
+ const payload = await apiClient.getClusterMetrics({ clusterName });
|
|
|
|
+ dispatch(actions.fetchClusterMetricsAction.success(payload));
|
|
|
|
+ } catch (e) {
|
|
|
|
+ dispatch(actions.fetchClusterMetricsAction.failure());
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
export const fetchBrokers = (
|
|
export const fetchBrokers = (
|
|
clusterName: ClusterName
|
|
clusterName: ClusterName
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchBrokersAction.request());
|
|
dispatch(actions.fetchBrokersAction.request());
|
|
try {
|
|
try {
|
|
- const payload = await api.getBrokers(clusterName);
|
|
|
|
|
|
+ const payload = await apiClient.getBrokers({ clusterName });
|
|
dispatch(actions.fetchBrokersAction.success(payload));
|
|
dispatch(actions.fetchBrokersAction.success(payload));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.fetchBrokersAction.failure());
|
|
dispatch(actions.fetchBrokersAction.failure());
|
|
@@ -25,36 +70,30 @@ export const fetchBrokers = (
|
|
};
|
|
};
|
|
|
|
|
|
export const fetchBrokerMetrics = (
|
|
export const fetchBrokerMetrics = (
|
|
- clusterName: ClusterName
|
|
|
|
|
|
+ clusterName: ClusterName,
|
|
|
|
+ brokerId: BrokerId
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchBrokerMetricsAction.request());
|
|
dispatch(actions.fetchBrokerMetricsAction.request());
|
|
try {
|
|
try {
|
|
- const payload = await api.getBrokerMetrics(clusterName);
|
|
|
|
|
|
+ const payload = await apiClient.getBrokersMetrics({
|
|
|
|
+ clusterName,
|
|
|
|
+ id: brokerId,
|
|
|
|
+ });
|
|
dispatch(actions.fetchBrokerMetricsAction.success(payload));
|
|
dispatch(actions.fetchBrokerMetricsAction.success(payload));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.fetchBrokerMetricsAction.failure());
|
|
dispatch(actions.fetchBrokerMetricsAction.failure());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-export const fetchClustersList = (): PromiseThunk<void> => async (dispatch) => {
|
|
|
|
- dispatch(actions.fetchClusterListAction.request());
|
|
|
|
- try {
|
|
|
|
- const clusters: Cluster[] = await api.getClusters();
|
|
|
|
- dispatch(actions.fetchClusterListAction.success(clusters));
|
|
|
|
- } catch (e) {
|
|
|
|
- dispatch(actions.fetchClusterListAction.failure());
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-export const fetchTopicList = (
|
|
|
|
|
|
+export const fetchTopicsList = (
|
|
clusterName: ClusterName
|
|
clusterName: ClusterName
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
- dispatch(actions.fetchTopicListAction.request());
|
|
|
|
|
|
+ dispatch(actions.fetchTopicsListAction.request());
|
|
try {
|
|
try {
|
|
- const topics = await api.getTopics(clusterName);
|
|
|
|
- dispatch(actions.fetchTopicListAction.success(topics));
|
|
|
|
|
|
+ const topics = await apiClient.getTopics({ clusterName });
|
|
|
|
+ dispatch(actions.fetchTopicsListAction.success(topics));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- dispatch(actions.fetchTopicListAction.failure());
|
|
|
|
|
|
+ dispatch(actions.fetchTopicsListAction.failure());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -65,11 +104,11 @@ export const fetchTopicMessages = (
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchTopicMessagesAction.request());
|
|
dispatch(actions.fetchTopicMessagesAction.request());
|
|
try {
|
|
try {
|
|
- const messages = await api.getTopicMessages(
|
|
|
|
|
|
+ const messages = await apiClient.getTopicMessages({
|
|
clusterName,
|
|
clusterName,
|
|
topicName,
|
|
topicName,
|
|
- queryParams
|
|
|
|
- );
|
|
|
|
|
|
+ ...queryParams,
|
|
|
|
+ });
|
|
dispatch(actions.fetchTopicMessagesAction.success(messages));
|
|
dispatch(actions.fetchTopicMessagesAction.success(messages));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.fetchTopicMessagesAction.failure());
|
|
dispatch(actions.fetchTopicMessagesAction.failure());
|
|
@@ -82,7 +121,10 @@ export const fetchTopicDetails = (
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchTopicDetailsAction.request());
|
|
dispatch(actions.fetchTopicDetailsAction.request());
|
|
try {
|
|
try {
|
|
- const topicDetails = await api.getTopicDetails(clusterName, topicName);
|
|
|
|
|
|
+ const topicDetails = await apiClient.getTopicDetails({
|
|
|
|
+ clusterName,
|
|
|
|
+ topicName,
|
|
|
|
+ });
|
|
dispatch(
|
|
dispatch(
|
|
actions.fetchTopicDetailsAction.success({
|
|
actions.fetchTopicDetailsAction.success({
|
|
topicName,
|
|
topicName,
|
|
@@ -100,20 +142,59 @@ export const fetchTopicConfig = (
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchTopicConfigAction.request());
|
|
dispatch(actions.fetchTopicConfigAction.request());
|
|
try {
|
|
try {
|
|
- const config = await api.getTopicConfig(clusterName, topicName);
|
|
|
|
|
|
+ const config = await apiClient.getTopicConfigs({ clusterName, topicName });
|
|
dispatch(actions.fetchTopicConfigAction.success({ topicName, config }));
|
|
dispatch(actions.fetchTopicConfigAction.success({ topicName, config }));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.fetchTopicConfigAction.failure());
|
|
dispatch(actions.fetchTopicConfigAction.failure());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const formatTopicFormData = (form: TopicFormDataRaw): TopicFormData => {
|
|
|
|
+ const {
|
|
|
|
+ name,
|
|
|
|
+ partitions,
|
|
|
|
+ replicationFactor,
|
|
|
|
+ cleanupPolicy,
|
|
|
|
+ retentionBytes,
|
|
|
|
+ retentionMs,
|
|
|
|
+ maxMessageBytes,
|
|
|
|
+ minInSyncReplicas,
|
|
|
|
+ customParams,
|
|
|
|
+ } = form;
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ name,
|
|
|
|
+ partitions,
|
|
|
|
+ replicationFactor,
|
|
|
|
+ configs: {
|
|
|
|
+ 'cleanup.policy': cleanupPolicy,
|
|
|
|
+ 'retention.ms': retentionMs,
|
|
|
|
+ 'retention.bytes': retentionBytes,
|
|
|
|
+ 'max.message.bytes': maxMessageBytes,
|
|
|
|
+ 'min.insync.replicas': minInSyncReplicas,
|
|
|
|
+ ...Object.values(customParams || {}).reduce(
|
|
|
|
+ (result: TopicFormFormattedParams, customParam: TopicConfig) => {
|
|
|
|
+ return {
|
|
|
|
+ ...result,
|
|
|
|
+ [customParam.name]: customParam.value,
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ {}
|
|
|
|
+ ),
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+};
|
|
|
|
+
|
|
export const createTopic = (
|
|
export const createTopic = (
|
|
clusterName: ClusterName,
|
|
clusterName: ClusterName,
|
|
- form: TopicFormData
|
|
|
|
|
|
+ form: TopicFormDataRaw
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.createTopicAction.request());
|
|
dispatch(actions.createTopicAction.request());
|
|
try {
|
|
try {
|
|
- const topic: Topic = await api.postTopic(clusterName, form);
|
|
|
|
|
|
+ const topic: Topic = await apiClient.createTopic({
|
|
|
|
+ clusterName,
|
|
|
|
+ topicFormData: formatTopicFormData(form),
|
|
|
|
+ });
|
|
dispatch(actions.createTopicAction.success(topic));
|
|
dispatch(actions.createTopicAction.success(topic));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.createTopicAction.failure());
|
|
dispatch(actions.createTopicAction.failure());
|
|
@@ -122,11 +203,15 @@ export const createTopic = (
|
|
|
|
|
|
export const updateTopic = (
|
|
export const updateTopic = (
|
|
clusterName: ClusterName,
|
|
clusterName: ClusterName,
|
|
- form: TopicFormData
|
|
|
|
|
|
+ form: TopicFormDataRaw
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.updateTopicAction.request());
|
|
dispatch(actions.updateTopicAction.request());
|
|
try {
|
|
try {
|
|
- const topic: Topic = await api.patchTopic(clusterName, form);
|
|
|
|
|
|
+ const topic: Topic = await apiClient.updateTopic({
|
|
|
|
+ clusterName,
|
|
|
|
+ topicName: form.name,
|
|
|
|
+ topicFormData: formatTopicFormData(form),
|
|
|
|
+ });
|
|
dispatch(actions.updateTopicAction.success(topic));
|
|
dispatch(actions.updateTopicAction.success(topic));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.updateTopicAction.failure());
|
|
dispatch(actions.updateTopicAction.failure());
|
|
@@ -138,7 +223,7 @@ export const fetchConsumerGroupsList = (
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchConsumerGroupsAction.request());
|
|
dispatch(actions.fetchConsumerGroupsAction.request());
|
|
try {
|
|
try {
|
|
- const consumerGroups = await api.getConsumerGroups(clusterName);
|
|
|
|
|
|
+ const consumerGroups = await apiClient.getConsumerGroups({ clusterName });
|
|
dispatch(actions.fetchConsumerGroupsAction.success(consumerGroups));
|
|
dispatch(actions.fetchConsumerGroupsAction.success(consumerGroups));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
dispatch(actions.fetchConsumerGroupsAction.failure());
|
|
dispatch(actions.fetchConsumerGroupsAction.failure());
|
|
@@ -151,10 +236,10 @@ export const fetchConsumerGroupDetails = (
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
): PromiseThunk<void> => async (dispatch) => {
|
|
dispatch(actions.fetchConsumerGroupDetailsAction.request());
|
|
dispatch(actions.fetchConsumerGroupDetailsAction.request());
|
|
try {
|
|
try {
|
|
- const consumerGroupDetails = await api.getConsumerGroupDetails(
|
|
|
|
|
|
+ const consumerGroupDetails = await apiClient.getConsumerGroup({
|
|
clusterName,
|
|
clusterName,
|
|
- consumerGroupID
|
|
|
|
- );
|
|
|
|
|
|
+ id: consumerGroupID,
|
|
|
|
+ });
|
|
dispatch(
|
|
dispatch(
|
|
actions.fetchConsumerGroupDetailsAction.success({
|
|
actions.fetchConsumerGroupDetailsAction.success({
|
|
consumerGroupID,
|
|
consumerGroupID,
|