additional improvements to the docs of the event controller (event filters)
This commit is contained in:
parent
72d7c0bb29
commit
33c6aeccff
@ -130,17 +130,47 @@ public class ControllerConstants {
|
|||||||
|
|
||||||
protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n";
|
protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n";
|
||||||
protected static final String MARKDOWN_CODE_BLOCK_END = "\n```";
|
protected static final String MARKDOWN_CODE_BLOCK_END = "\n```";
|
||||||
protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"ERROR\", \"server\": \"ip-172-31-24-152\", " +
|
protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START +
|
||||||
"\"method\": \"onClusterEventMsg\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END;
|
"{\n" +
|
||||||
protected static final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"LC_EVENT\", \"server\": \"ip-172-31-24-152\", \"event\":" +
|
" \"eventType\":\"ERROR\",\n" +
|
||||||
" \"STARTED\", \"status\": \"Success\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END;
|
" \"server\":\"ip-172-31-24-152\",\n" +
|
||||||
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;
|
" \"method\":\"onClusterEventMsg\",\n" +
|
||||||
protected static final String DEBUG_FILTER_OBJ = "\"msgDirectionType\": \"IN\", \"server\": \"ip-172-31-24-152\", \"dataSearch\": \"humidity\", " +
|
" \"errorStr\":\"Error Message\"\n" +
|
||||||
"\"metadataSearch\": \"deviceName\", \"entityName\": \"DEVICE\", \"relationType\": \"Success\"," +
|
"}" +
|
||||||
" \"entityId\": \"de9d54a0-2b7a-11ec-a3cc-23386423d98f\", \"msgType\": \"POST_TELEMETRY_REQUEST\"," +
|
MARKDOWN_CODE_BLOCK_END;
|
||||||
" \"isError\": \"false\", \"error\": \"Error Message\" }";
|
protected static final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START +
|
||||||
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;
|
"{\n" +
|
||||||
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;
|
" \"eventType\":\"LC_EVENT\",\n" +
|
||||||
|
" \"server\":\"ip-172-31-24-152\",\n" +
|
||||||
|
" \"event\":\"STARTED\",\n" +
|
||||||
|
" \"status\":\"Success\",\n" +
|
||||||
|
" \"errorStr\":\"Error Message\"\n" +
|
||||||
|
"}" +
|
||||||
|
MARKDOWN_CODE_BLOCK_END;
|
||||||
|
protected static final String EVENT_STATS_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START +
|
||||||
|
"{\n" +
|
||||||
|
" \"eventType\":\"STATS\",\n" +
|
||||||
|
" \"server\":\"ip-172-31-24-152\",\n" +
|
||||||
|
" \"messagesProcessed\":10,\n" +
|
||||||
|
" \"errorsOccurred\":5\n" +
|
||||||
|
"}" +
|
||||||
|
MARKDOWN_CODE_BLOCK_END;
|
||||||
|
protected static final String DEBUG_FILTER_OBJ =
|
||||||
|
" \"msgDirectionType\":\"IN\",\n" +
|
||||||
|
" \"server\":\"ip-172-31-24-152\",\n" +
|
||||||
|
" \"dataSearch\":\"humidity\",\n" +
|
||||||
|
" \"metadataSearch\":\"deviceName\",\n" +
|
||||||
|
" \"entityName\":\"DEVICE\",\n" +
|
||||||
|
" \"relationType\":\"Success\",\n" +
|
||||||
|
" \"entityId\":\"de9d54a0-2b7a-11ec-a3cc-23386423d98f\",\n" +
|
||||||
|
" \"msgType\":\"POST_TELEMETRY_REQUEST\",\n" +
|
||||||
|
" \"isError\":\"false\",\n" +
|
||||||
|
" \"errorStr\":\"Error Message\"\n" +
|
||||||
|
"}";
|
||||||
|
protected static final String EVENT_DEBUG_RULE_NODE_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{\n" +
|
||||||
|
" \"eventType\":\"DEBUG_RULE_NODE\",\n" + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END;
|
||||||
|
protected static final String EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{\n" +
|
||||||
|
" \"eventType\":\"DEBUG_RULE_CHAIN\",\n" + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END;
|
||||||
|
|
||||||
protected static final String FILTER_VALUE_TYPE = NEW_LINE + "## Value Type and Operations" + NEW_LINE +
|
protected static final String FILTER_VALUE_TYPE = NEW_LINE + "## Value Type and Operations" + NEW_LINE +
|
||||||
"Provides a hint about the data type of the entity field that is defined in the filter key. " +
|
"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
|
|||||||
@RequestMapping("/api")
|
@RequestMapping("/api")
|
||||||
public class EventController extends BaseController {
|
public class EventController extends BaseController {
|
||||||
|
|
||||||
|
private static final String EVENT_FILTER_DEFINITION = "# Event Filter Definition" + NEW_LINE +
|
||||||
|
"5 different eventFilter objects could be set for different event types. " +
|
||||||
|
"The eventType field is required. Others are optional. If some of them are set, the filtering will be applied according to them. " +
|
||||||
|
"See the examples below for all the fields used for each event type filtering. " + NEW_LINE +
|
||||||
|
"Note," + NEW_LINE +
|
||||||
|
" * 'server' - string value representing the server name, identifier or ip address where the platform is running;\n" +
|
||||||
|
" * 'errorStr' - the case insensitive 'contains' filter based on error message." + NEW_LINE +
|
||||||
|
"## Error Event Filter" + NEW_LINE +
|
||||||
|
EVENT_ERROR_FILTER_OBJ + NEW_LINE +
|
||||||
|
" * 'method' - string value representing the method name when the error happened." + NEW_LINE +
|
||||||
|
"## Lifecycle Event Filter" + NEW_LINE +
|
||||||
|
EVENT_LC_EVENT_FILTER_OBJ + NEW_LINE +
|
||||||
|
" * 'event' - string value representing the lifecycle event type;\n" +
|
||||||
|
" * 'status' - string value representing status of the lifecycle event." + NEW_LINE +
|
||||||
|
"## Statistics Event Filter" + NEW_LINE +
|
||||||
|
EVENT_STATS_FILTER_OBJ + NEW_LINE +
|
||||||
|
" * 'messagesProcessed' - the minimum number of successfully processed messages;\n" +
|
||||||
|
" * 'errorsOccurred' - the minimum number of errors occurred during messages processing." + NEW_LINE +
|
||||||
|
"## Debug Rule Node Event Filter" + NEW_LINE +
|
||||||
|
EVENT_DEBUG_RULE_NODE_FILTER_OBJ + NEW_LINE +
|
||||||
|
"## Debug Rule Chain Event Filter" + NEW_LINE +
|
||||||
|
EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ + NEW_LINE +
|
||||||
|
" * 'msgDirectionType' - string value representing msg direction type (incoming to entity or outcoming from entity);\n" +
|
||||||
|
" * 'dataSearch' - the case insensitive 'contains' filter based on data (key and value) for the message;\n" +
|
||||||
|
" * 'metadataSearch' - the case insensitive 'contains' filter based on metadata (key and value) for the message;\n" +
|
||||||
|
" * 'entityName' - string value representing the entity type;\n" +
|
||||||
|
" * 'relationType' - string value representing the type of message routing;\n" +
|
||||||
|
" * 'entityId' - string value representing the entity id in the event body (originator of the message);\n" +
|
||||||
|
" * 'msgType' - string value representing the message type;\n" +
|
||||||
|
" * 'isError' - boolean value to filter the errors." + NEW_LINE;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EventService eventService;
|
private EventService eventService;
|
||||||
|
|
||||||
@ -159,14 +190,8 @@ public class EventController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation(value = "Get Events by event filter (getEvents)",
|
@ApiOperation(value = "Get Events by event filter (getEvents)",
|
||||||
notes = "Returns a page of events for the chosen entity by specifying the event filter. " +
|
notes = "Returns a page of events for the chosen entity by specifying the event filter. " +
|
||||||
PAGE_DATA_PARAMETERS + NEW_LINE + "5 different eventFilter objects could be set for different event types. " +
|
PAGE_DATA_PARAMETERS + NEW_LINE +
|
||||||
"The eventType field is required. Others are optional. If some of them are set, the filtering will be applied according to them. " +
|
EVENT_FILTER_DEFINITION,
|
||||||
"See the examples below for all the fields used for each event type filtering. " + NEW_LINE +
|
|
||||||
EVENT_ERROR_FILTER_OBJ + NEW_LINE +
|
|
||||||
EVENT_LC_EVENT_FILTER_OBJ + NEW_LINE +
|
|
||||||
EVENT_STATS_FILTER_OBJ + NEW_LINE +
|
|
||||||
EVENT_DEBUG_RULE_NODE_FILTER_OBJ + NEW_LINE +
|
|
||||||
EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ + NEW_LINE,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.POST)
|
@RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.POST)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user