|
@@ -1,3 +1,4 @@
|
|
|
|
+import { reduce } from 'lodash';
|
|
import {
|
|
import {
|
|
TopicName,
|
|
TopicName,
|
|
Topic,
|
|
Topic,
|
|
@@ -5,6 +6,7 @@ import {
|
|
TopicDetails,
|
|
TopicDetails,
|
|
TopicConfig,
|
|
TopicConfig,
|
|
TopicFormData,
|
|
TopicFormData,
|
|
|
|
+ TopicFormCustomParam,
|
|
} from 'redux/interfaces';
|
|
} from 'redux/interfaces';
|
|
import {
|
|
import {
|
|
BASE_URL,
|
|
BASE_URL,
|
|
@@ -23,6 +25,10 @@ export const getTopics = (clusterName: ClusterName): Promise<Topic[]> =>
|
|
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
|
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
|
.then(res => res.json());
|
|
.then(res => res.json());
|
|
|
|
|
|
|
|
+interface Result {
|
|
|
|
+ [index: string]: string,
|
|
|
|
+}
|
|
|
|
+
|
|
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
|
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
|
const {
|
|
const {
|
|
name,
|
|
name,
|
|
@@ -34,6 +40,12 @@ export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promis
|
|
maxMessageBytes,
|
|
maxMessageBytes,
|
|
minInSyncReplicas,
|
|
minInSyncReplicas,
|
|
} = form;
|
|
} = form;
|
|
|
|
+
|
|
|
|
+ const customParams = reduce(Object.values(form.customParams), (result: Result, customParam: TopicFormCustomParam) => {
|
|
|
|
+ result[customParam.name] = customParam.value;
|
|
|
|
+ return result;
|
|
|
|
+ }, {});
|
|
|
|
+
|
|
const body = JSON.stringify({
|
|
const body = JSON.stringify({
|
|
name,
|
|
name,
|
|
partitions,
|
|
partitions,
|
|
@@ -44,8 +56,10 @@ export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promis
|
|
'retention.bytes': retentionBytes,
|
|
'retention.bytes': retentionBytes,
|
|
'max.message.bytes': maxMessageBytes,
|
|
'max.message.bytes': maxMessageBytes,
|
|
'min.insync.replicas': minInSyncReplicas,
|
|
'min.insync.replicas': minInSyncReplicas,
|
|
|
|
+ ...customParams,
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
return fetch(`${BASE_URL}/clusters/${clusterName}/topics`, {
|
|
return fetch(`${BASE_URL}/clusters/${clusterName}/topics`, {
|
|
...BASE_PARAMS,
|
|
...BASE_PARAMS,
|
|
method: 'POST',
|
|
method: 'POST',
|