Commit 33c6aeccff507d01cae858b6c5d132c37f1cfe33
Committed by
Andrew Shvayka
1 parent
72d7c0bb
additional improvements to the docs of the event controller (event filters)
Showing
2 changed files
with
74 additions
and
19 deletions
... | ... | @@ -130,17 +130,47 @@ public class ControllerConstants { |
130 | 130 | |
131 | 131 | protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n"; |
132 | 132 | protected static final String MARKDOWN_CODE_BLOCK_END = "\n```"; |
133 | - protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"ERROR\", \"server\": \"ip-172-31-24-152\", " + | |
134 | - "\"method\": \"onClusterEventMsg\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END; | |
135 | - protected static final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"LC_EVENT\", \"server\": \"ip-172-31-24-152\", \"event\":" + | |
136 | - " \"STARTED\", \"status\": \"Success\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END; | |
137 | - protected static final String EVENT_STATS_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"STATS\", \"server\": \"ip-172-31-24-152\", \"messagesProcessed\": 10, \"errorsOccurred\": 5 }" + MARKDOWN_CODE_BLOCK_END; | |
138 | - protected static final String DEBUG_FILTER_OBJ = "\"msgDirectionType\": \"IN\", \"server\": \"ip-172-31-24-152\", \"dataSearch\": \"humidity\", " + | |
139 | - "\"metadataSearch\": \"deviceName\", \"entityName\": \"DEVICE\", \"relationType\": \"Success\"," + | |
140 | - " \"entityId\": \"de9d54a0-2b7a-11ec-a3cc-23386423d98f\", \"msgType\": \"POST_TELEMETRY_REQUEST\"," + | |
141 | - " \"isError\": \"false\", \"error\": \"Error Message\" }"; | |
142 | - protected static final String EVENT_DEBUG_RULE_NODE_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"DEBUG_RULE_NODE\"," + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END; | |
143 | - protected static final String EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"DEBUG_RULE_CHAIN\"," + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END; | |
133 | + protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + | |
134 | + "{\n" + | |
135 | + " \"eventType\":\"ERROR\",\n" + | |
136 | + " \"server\":\"ip-172-31-24-152\",\n" + | |
137 | + " \"method\":\"onClusterEventMsg\",\n" + | |
138 | + " \"errorStr\":\"Error Message\"\n" + | |
139 | + "}" + | |
140 | + MARKDOWN_CODE_BLOCK_END; | |
141 | + protected static final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + | |
142 | + "{\n" + | |
143 | + " \"eventType\":\"LC_EVENT\",\n" + | |
144 | + " \"server\":\"ip-172-31-24-152\",\n" + | |
145 | + " \"event\":\"STARTED\",\n" + | |
146 | + " \"status\":\"Success\",\n" + | |
147 | + " \"errorStr\":\"Error Message\"\n" + | |
148 | + "}" + | |
149 | + MARKDOWN_CODE_BLOCK_END; | |
150 | + protected static final String EVENT_STATS_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + | |
151 | + "{\n" + | |
152 | + " \"eventType\":\"STATS\",\n" + | |
153 | + " \"server\":\"ip-172-31-24-152\",\n" + | |
154 | + " \"messagesProcessed\":10,\n" + | |
155 | + " \"errorsOccurred\":5\n" + | |
156 | + "}" + | |
157 | + MARKDOWN_CODE_BLOCK_END; | |
158 | + protected static final String DEBUG_FILTER_OBJ = | |
159 | + " \"msgDirectionType\":\"IN\",\n" + | |
160 | + " \"server\":\"ip-172-31-24-152\",\n" + | |
161 | + " \"dataSearch\":\"humidity\",\n" + | |
162 | + " \"metadataSearch\":\"deviceName\",\n" + | |
163 | + " \"entityName\":\"DEVICE\",\n" + | |
164 | + " \"relationType\":\"Success\",\n" + | |
165 | + " \"entityId\":\"de9d54a0-2b7a-11ec-a3cc-23386423d98f\",\n" + | |
166 | + " \"msgType\":\"POST_TELEMETRY_REQUEST\",\n" + | |
167 | + " \"isError\":\"false\",\n" + | |
168 | + " \"errorStr\":\"Error Message\"\n" + | |
169 | + "}"; | |
170 | + protected static final String EVENT_DEBUG_RULE_NODE_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{\n" + | |
171 | + " \"eventType\":\"DEBUG_RULE_NODE\",\n" + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END; | |
172 | + protected static final String EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{\n" + | |
173 | + " \"eventType\":\"DEBUG_RULE_CHAIN\",\n" + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END; | |
144 | 174 | |
145 | 175 | protected static final String FILTER_VALUE_TYPE = NEW_LINE + "## Value Type and Operations" + NEW_LINE + |
146 | 176 | "Provides a hint about the data type of the entity field that is defined in the filter key. " + | ... | ... |
... | ... | @@ -68,6 +68,37 @@ import static org.thingsboard.server.controller.ControllerConstants.TENANT_ID_PA |
68 | 68 | @RequestMapping("/api") |
69 | 69 | public class EventController extends BaseController { |
70 | 70 | |
71 | + private static final String EVENT_FILTER_DEFINITION = "# Event Filter Definition" + NEW_LINE + | |
72 | + "5 different eventFilter objects could be set for different event types. " + | |
73 | + "The eventType field is required. Others are optional. If some of them are set, the filtering will be applied according to them. " + | |
74 | + "See the examples below for all the fields used for each event type filtering. " + NEW_LINE + | |
75 | + "Note," + NEW_LINE + | |
76 | + " * 'server' - string value representing the server name, identifier or ip address where the platform is running;\n" + | |
77 | + " * 'errorStr' - the case insensitive 'contains' filter based on error message." + NEW_LINE + | |
78 | + "## Error Event Filter" + NEW_LINE + | |
79 | + EVENT_ERROR_FILTER_OBJ + NEW_LINE + | |
80 | + " * 'method' - string value representing the method name when the error happened." + NEW_LINE + | |
81 | + "## Lifecycle Event Filter" + NEW_LINE + | |
82 | + EVENT_LC_EVENT_FILTER_OBJ + NEW_LINE + | |
83 | + " * 'event' - string value representing the lifecycle event type;\n" + | |
84 | + " * 'status' - string value representing status of the lifecycle event." + NEW_LINE + | |
85 | + "## Statistics Event Filter" + NEW_LINE + | |
86 | + EVENT_STATS_FILTER_OBJ + NEW_LINE + | |
87 | + " * 'messagesProcessed' - the minimum number of successfully processed messages;\n" + | |
88 | + " * 'errorsOccurred' - the minimum number of errors occurred during messages processing." + NEW_LINE + | |
89 | + "## Debug Rule Node Event Filter" + NEW_LINE + | |
90 | + EVENT_DEBUG_RULE_NODE_FILTER_OBJ + NEW_LINE + | |
91 | + "## Debug Rule Chain Event Filter" + NEW_LINE + | |
92 | + EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ + NEW_LINE + | |
93 | + " * 'msgDirectionType' - string value representing msg direction type (incoming to entity or outcoming from entity);\n" + | |
94 | + " * 'dataSearch' - the case insensitive 'contains' filter based on data (key and value) for the message;\n" + | |
95 | + " * 'metadataSearch' - the case insensitive 'contains' filter based on metadata (key and value) for the message;\n" + | |
96 | + " * 'entityName' - string value representing the entity type;\n" + | |
97 | + " * 'relationType' - string value representing the type of message routing;\n" + | |
98 | + " * 'entityId' - string value representing the entity id in the event body (originator of the message);\n" + | |
99 | + " * 'msgType' - string value representing the message type;\n" + | |
100 | + " * 'isError' - boolean value to filter the errors." + NEW_LINE; | |
101 | + | |
71 | 102 | @Autowired |
72 | 103 | private EventService eventService; |
73 | 104 | |
... | ... | @@ -159,14 +190,8 @@ public class EventController extends BaseController { |
159 | 190 | |
160 | 191 | @ApiOperation(value = "Get Events by event filter (getEvents)", |
161 | 192 | notes = "Returns a page of events for the chosen entity by specifying the event filter. " + |
162 | - PAGE_DATA_PARAMETERS + NEW_LINE + "5 different eventFilter objects could be set for different event types. " + | |
163 | - "The eventType field is required. Others are optional. If some of them are set, the filtering will be applied according to them. " + | |
164 | - "See the examples below for all the fields used for each event type filtering. " + NEW_LINE + | |
165 | - EVENT_ERROR_FILTER_OBJ + NEW_LINE + | |
166 | - EVENT_LC_EVENT_FILTER_OBJ + NEW_LINE + | |
167 | - EVENT_STATS_FILTER_OBJ + NEW_LINE + | |
168 | - EVENT_DEBUG_RULE_NODE_FILTER_OBJ + NEW_LINE + | |
169 | - EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ + NEW_LINE, | |
193 | + PAGE_DATA_PARAMETERS + NEW_LINE + | |
194 | + EVENT_FILTER_DEFINITION, | |
170 | 195 | produces = MediaType.APPLICATION_JSON_VALUE) |
171 | 196 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
172 | 197 | @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.POST) | ... | ... |