actions.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import { createAction, createAsyncAction } from 'typesafe-actions';
  2. import {
  3. ConsumerGroupID,
  4. FailurePayload,
  5. TopicName,
  6. TopicsState,
  7. ConnectorName,
  8. ConnectorConfig,
  9. } from 'redux/interfaces';
  10. import {
  11. Cluster,
  12. ClusterStats,
  13. ClusterMetrics,
  14. Broker,
  15. BrokerMetrics,
  16. TopicMessage,
  17. ConsumerGroup,
  18. ConsumerGroupDetails,
  19. SchemaSubject,
  20. CompatibilityLevelCompatibilityEnum,
  21. TopicColumnsToSort,
  22. Connector,
  23. FullConnectorInfo,
  24. Connect,
  25. Task,
  26. } from 'generated-sources';
  27. export const fetchClusterStatsAction = createAsyncAction(
  28. 'GET_CLUSTER_STATUS__REQUEST',
  29. 'GET_CLUSTER_STATUS__SUCCESS',
  30. 'GET_CLUSTER_STATUS__FAILURE'
  31. )<undefined, ClusterStats, undefined>();
  32. export const fetchClusterMetricsAction = createAsyncAction(
  33. 'GET_CLUSTER_METRICS__REQUEST',
  34. 'GET_CLUSTER_METRICS__SUCCESS',
  35. 'GET_CLUSTER_METRICS__FAILURE'
  36. )<undefined, ClusterMetrics, undefined>();
  37. export const fetchBrokersAction = createAsyncAction(
  38. 'GET_BROKERS__REQUEST',
  39. 'GET_BROKERS__SUCCESS',
  40. 'GET_BROKERS__FAILURE'
  41. )<undefined, Broker[], undefined>();
  42. export const fetchBrokerMetricsAction = createAsyncAction(
  43. 'GET_BROKER_METRICS__REQUEST',
  44. 'GET_BROKER_METRICS__SUCCESS',
  45. 'GET_BROKER_METRICS__FAILURE'
  46. )<undefined, BrokerMetrics, undefined>();
  47. export const fetchClusterListAction = createAsyncAction(
  48. 'GET_CLUSTERS__REQUEST',
  49. 'GET_CLUSTERS__SUCCESS',
  50. 'GET_CLUSTERS__FAILURE'
  51. )<undefined, Cluster[], undefined>();
  52. export const fetchTopicsListAction = createAsyncAction(
  53. 'GET_TOPICS__REQUEST',
  54. 'GET_TOPICS__SUCCESS',
  55. 'GET_TOPICS__FAILURE'
  56. )<undefined, TopicsState, undefined>();
  57. export const fetchTopicMessagesAction = createAsyncAction(
  58. 'GET_TOPIC_MESSAGES__REQUEST',
  59. 'GET_TOPIC_MESSAGES__SUCCESS',
  60. 'GET_TOPIC_MESSAGES__FAILURE'
  61. )<undefined, TopicMessage[], undefined>();
  62. export const clearMessagesTopicAction = createAsyncAction(
  63. 'CLEAR_TOPIC_MESSAGES__REQUEST',
  64. 'CLEAR_TOPIC_MESSAGES__SUCCESS',
  65. 'CLEAR_TOPIC_MESSAGES__FAILURE'
  66. )<undefined, TopicName, { alert?: FailurePayload }>();
  67. export const fetchTopicDetailsAction = createAsyncAction(
  68. 'GET_TOPIC_DETAILS__REQUEST',
  69. 'GET_TOPIC_DETAILS__SUCCESS',
  70. 'GET_TOPIC_DETAILS__FAILURE'
  71. )<undefined, TopicsState, undefined>();
  72. export const fetchTopicConfigAction = createAsyncAction(
  73. 'GET_TOPIC_CONFIG__REQUEST',
  74. 'GET_TOPIC_CONFIG__SUCCESS',
  75. 'GET_TOPIC_CONFIG__FAILURE'
  76. )<undefined, TopicsState, undefined>();
  77. export const createTopicAction = createAsyncAction(
  78. 'POST_TOPIC__REQUEST',
  79. 'POST_TOPIC__SUCCESS',
  80. 'POST_TOPIC__FAILURE'
  81. )<undefined, TopicsState, { alert?: FailurePayload }>();
  82. export const updateTopicAction = createAsyncAction(
  83. 'PATCH_TOPIC__REQUEST',
  84. 'PATCH_TOPIC__SUCCESS',
  85. 'PATCH_TOPIC__FAILURE'
  86. )<undefined, TopicsState, undefined>();
  87. export const deleteTopicAction = createAsyncAction(
  88. 'DELETE_TOPIC__REQUEST',
  89. 'DELETE_TOPIC__SUCCESS',
  90. 'DELETE_TOPIC__FAILURE'
  91. )<undefined, TopicName, undefined>();
  92. export const fetchConsumerGroupsAction = createAsyncAction(
  93. 'GET_CONSUMER_GROUPS__REQUEST',
  94. 'GET_CONSUMER_GROUPS__SUCCESS',
  95. 'GET_CONSUMER_GROUPS__FAILURE'
  96. )<undefined, ConsumerGroup[], undefined>();
  97. export const fetchConsumerGroupDetailsAction = createAsyncAction(
  98. 'GET_CONSUMER_GROUP_DETAILS__REQUEST',
  99. 'GET_CONSUMER_GROUP_DETAILS__SUCCESS',
  100. 'GET_CONSUMER_GROUP_DETAILS__FAILURE'
  101. )<
  102. undefined,
  103. { consumerGroupID: ConsumerGroupID; details: ConsumerGroupDetails },
  104. undefined
  105. >();
  106. export const fetchSchemasByClusterNameAction = createAsyncAction(
  107. 'GET_CLUSTER_SCHEMAS__REQUEST',
  108. 'GET_CLUSTER_SCHEMAS__SUCCESS',
  109. 'GET_CLUSTER_SCHEMAS__FAILURE'
  110. )<undefined, SchemaSubject[], undefined>();
  111. export const fetchGlobalSchemaCompatibilityLevelAction = createAsyncAction(
  112. 'GET_GLOBAL_SCHEMA_COMPATIBILITY__REQUEST',
  113. 'GET_GLOBAL_SCHEMA_COMPATIBILITY__SUCCESS',
  114. 'GET_GLOBAL_SCHEMA_COMPATIBILITY__FAILURE'
  115. )<undefined, CompatibilityLevelCompatibilityEnum, undefined>();
  116. export const updateGlobalSchemaCompatibilityLevelAction = createAsyncAction(
  117. 'PUT_GLOBAL_SCHEMA_COMPATIBILITY__REQUEST',
  118. 'PUT_GLOBAL_SCHEMA_COMPATIBILITY__SUCCESS',
  119. 'PUT_GLOBAL_SCHEMA_COMPATIBILITY__FAILURE'
  120. )<undefined, CompatibilityLevelCompatibilityEnum, undefined>();
  121. export const fetchSchemaVersionsAction = createAsyncAction(
  122. 'GET_SCHEMA_VERSIONS__REQUEST',
  123. 'GET_SCHEMA_VERSIONS__SUCCESS',
  124. 'GET_SCHEMA_VERSIONS__FAILURE'
  125. )<undefined, SchemaSubject[], undefined>();
  126. export const createSchemaAction = createAsyncAction(
  127. 'POST_SCHEMA__REQUEST',
  128. 'POST_SCHEMA__SUCCESS',
  129. 'POST_SCHEMA__FAILURE'
  130. )<undefined, SchemaSubject, { alert?: FailurePayload }>();
  131. export const updateSchemaAction = createAsyncAction(
  132. 'PATCH_SCHEMA__REQUEST',
  133. 'PATCH_SCHEMA__SUCCESS',
  134. 'PATCH_SCHEMA__FAILURE'
  135. )<undefined, SchemaSubject, { alert?: FailurePayload }>();
  136. export const deleteSchemaAction = createAsyncAction(
  137. 'DELETE_SCHEMA__REQUEST',
  138. 'DELETE_SCHEMA__SUCCESS',
  139. 'DELETE_SCHEMA__FAILURE'
  140. )<undefined, string, { alert?: FailurePayload }>();
  141. export const dismissAlert = createAction('DISMISS_ALERT')<string>();
  142. export const fetchConnectsAction = createAsyncAction(
  143. 'GET_CONNECTS__REQUEST',
  144. 'GET_CONNECTS__SUCCESS',
  145. 'GET_CONNECTS__FAILURE'
  146. )<undefined, { connects: Connect[] }, { alert?: FailurePayload }>();
  147. export const fetchConnectorsAction = createAsyncAction(
  148. 'GET_CONNECTORS__REQUEST',
  149. 'GET_CONNECTORS__SUCCESS',
  150. 'GET_CONNECTORS__FAILURE'
  151. )<undefined, { connectors: FullConnectorInfo[] }, { alert?: FailurePayload }>();
  152. export const fetchConnectorAction = createAsyncAction(
  153. 'GET_CONNECTOR__REQUEST',
  154. 'GET_CONNECTOR__SUCCESS',
  155. 'GET_CONNECTOR__FAILURE'
  156. )<undefined, { connector: Connector }, { alert?: FailurePayload }>();
  157. export const createConnectorAction = createAsyncAction(
  158. 'POST_CONNECTOR__REQUEST',
  159. 'POST_CONNECTOR__SUCCESS',
  160. 'POST_CONNECTOR__FAILURE'
  161. )<undefined, { connector: Connector }, { alert?: FailurePayload }>();
  162. export const deleteConnectorAction = createAsyncAction(
  163. 'DELETE_CONNECTOR__REQUEST',
  164. 'DELETE_CONNECTOR__SUCCESS',
  165. 'DELETE_CONNECTOR__FAILURE'
  166. )<undefined, { connectorName: ConnectorName }, { alert?: FailurePayload }>();
  167. export const restartConnectorAction = createAsyncAction(
  168. 'RESTART_CONNECTOR__REQUEST',
  169. 'RESTART_CONNECTOR__SUCCESS',
  170. 'RESTART_CONNECTOR__FAILURE'
  171. )<undefined, undefined, { alert?: FailurePayload }>();
  172. export const pauseConnectorAction = createAsyncAction(
  173. 'PAUSE_CONNECTOR__REQUEST',
  174. 'PAUSE_CONNECTOR__SUCCESS',
  175. 'PAUSE_CONNECTOR__FAILURE'
  176. )<undefined, { connectorName: ConnectorName }, { alert?: FailurePayload }>();
  177. export const resumeConnectorAction = createAsyncAction(
  178. 'RESUME_CONNECTOR__REQUEST',
  179. 'RESUME_CONNECTOR__SUCCESS',
  180. 'RESUME_CONNECTOR__FAILURE'
  181. )<undefined, { connectorName: ConnectorName }, { alert?: FailurePayload }>();
  182. export const fetchConnectorTasksAction = createAsyncAction(
  183. 'GET_CONNECTOR_TASKS__REQUEST',
  184. 'GET_CONNECTOR_TASKS__SUCCESS',
  185. 'GET_CONNECTOR_TASKS__FAILURE'
  186. )<undefined, { tasks: Task[] }, { alert?: FailurePayload }>();
  187. export const restartConnectorTaskAction = createAsyncAction(
  188. 'RESTART_CONNECTOR_TASK__REQUEST',
  189. 'RESTART_CONNECTOR_TASK__SUCCESS',
  190. 'RESTART_CONNECTOR_TASK__FAILURE'
  191. )<undefined, undefined, { alert?: FailurePayload }>();
  192. export const fetchConnectorConfigAction = createAsyncAction(
  193. 'GET_CONNECTOR_CONFIG__REQUEST',
  194. 'GET_CONNECTOR_CONFIG__SUCCESS',
  195. 'GET_CONNECTOR_CONFIG__FAILURE'
  196. )<undefined, { config: ConnectorConfig }, { alert?: FailurePayload }>();
  197. export const updateConnectorConfigAction = createAsyncAction(
  198. 'PATCH_CONNECTOR_CONFIG__REQUEST',
  199. 'PATCH_CONNECTOR_CONFIG__SUCCESS',
  200. 'PATCH_CONNECTOR_CONFIG__FAILURE'
  201. )<undefined, { connector: Connector }, { alert?: FailurePayload }>();
  202. export const setTopicsSearchAction =
  203. createAction('SET_TOPICS_SEARCH')<string>();
  204. export const setTopicsOrderByAction = createAction(
  205. 'SET_TOPICS_ORDER_BY'
  206. )<TopicColumnsToSort>();