Commit 26c54f7a35170310645d8b35c2a29130e5b08dc9

Authored by Andrii Shvaika
2 parents 2c0f0136 2e6b839a

Audit log improvement

... ... @@ -65,8 +65,8 @@ public class AlarmController extends BaseController {
65 65 private static final String ALARM_QUERY_STATUS_DESCRIPTION = "A string value representing one of the AlarmStatus enumeration value";
66 66 private static final String ALARM_QUERY_STATUS_ALLOWABLE_VALUES = "ACTIVE_UNACK, ACTIVE_ACK, CLEARED_UNACK, CLEARED_ACK";
67 67 private static final String ALARM_QUERY_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on of next alarm fields: type, severity or status";
68   - private static final String ALARM_QUERY_START_TIME_DESCRIPTION = "The start timestamp(milliseconds) of the search time range over the alarm object field: 'createdTime'.";
69   - private static final String ALARM_QUERY_END_TIME_DESCRIPTION = "The end timestamp(milliseconds) of the search time range over the alarm object field: 'createdTime'.";
  68 + private static final String ALARM_QUERY_START_TIME_DESCRIPTION = "The start timestamp in milliseconds of the search time range over the Alarm class field: 'createdTime'.";
  69 + private static final String ALARM_QUERY_END_TIME_DESCRIPTION = "The end timestamp in milliseconds of the search time range over the Alarm class field: 'createdTime'.";
70 70 private static final String ALARM_QUERY_FETCH_ORIGINATOR_DESCRIPTION = "A boolean value to specify if the alarm originator name will be " +
71 71 "filled in the AlarmInfo object field: 'originatorName' or will returns as null.";
72 72
... ...
... ... @@ -15,7 +15,10 @@
15 15 */
16 16 package org.thingsboard.server.controller;
17 17
  18 +import io.swagger.annotations.ApiOperation;
  19 +import io.swagger.annotations.ApiParam;
18 20 import org.apache.commons.lang3.StringUtils;
  21 +import org.springframework.http.MediaType;
19 22 import org.springframework.security.access.prepost.PreAuthorize;
20 23 import org.springframework.web.bind.annotation.PathVariable;
21 24 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -44,18 +47,42 @@ import java.util.stream.Collectors;
44 47 @RequestMapping("/api")
45 48 public class AuditLogController extends BaseController {
46 49
  50 + private static final String AUDIT_LOG_QUERY_START_TIME_DESCRIPTION = "The start timestamp in milliseconds of the search time range over the AuditLog class field: 'createdTime'.";
  51 + private static final String AUDIT_LOG_QUERY_END_TIME_DESCRIPTION = "The end timestamp in milliseconds of the search time range over the AuditLog class field: 'createdTime'.";
  52 + private static final String AUDIT_LOG_QUERY_ACTION_TYPES_DESCRIPTION = "A String value representing comma-separated list of action types. " +
  53 + "This parameter is optional, but it can be used to filter results to fetch only audit logs of specific action types. " +
  54 + "For example, 'LOGIN', 'LOGOUT'. See the 'Model' tab of the Response Class for more details.";
  55 + private static final String AUDIT_LOG_SORT_PROPERTY_DESCRIPTION = "Property of audit log to sort by. " +
  56 + "See the 'Model' tab of the Response Class for more details. " +
  57 + "Note: entityType sort property is not defined in the AuditLog class, however, it can be used to sort audit logs by types of entities that were logged.";
  58 +
  59 +
  60 + @ApiOperation(value = "Get audit logs by customer id (getAuditLogsByCustomerId)",
  61 + notes = "Returns a page of audit logs related to the targeted customer entities (devices, assets, etc.), " +
  62 + "and users actions (login, logout, etc.) that belong to this customer. " +
  63 + PAGE_DATA_PARAMETERS + ADMINISTRATOR_AUTHORITY_ONLY,
  64 + produces = MediaType.APPLICATION_JSON_VALUE)
47 65 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
48 66 @RequestMapping(value = "/audit/logs/customer/{customerId}", params = {"pageSize", "page"}, method = RequestMethod.GET)
49 67 @ResponseBody
50 68 public PageData<AuditLog> getAuditLogsByCustomerId(
  69 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
51 70 @PathVariable("customerId") String strCustomerId,
  71 + @ApiParam(value = PAGE_SIZE_DESCRIPTION)
52 72 @RequestParam int pageSize,
  73 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
53 74 @RequestParam int page,
  75 + @ApiParam(value = AUDIT_LOG_TEXT_SEARCH_DESCRIPTION)
54 76 @RequestParam(required = false) String textSearch,
  77 + @ApiParam(value = AUDIT_LOG_SORT_PROPERTY_DESCRIPTION, allowableValues = AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES)
55 78 @RequestParam(required = false) String sortProperty,
  79 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
56 80 @RequestParam(required = false) String sortOrder,
  81 + @ApiParam(value = AUDIT_LOG_QUERY_START_TIME_DESCRIPTION)
57 82 @RequestParam(required = false) Long startTime,
  83 + @ApiParam(value = AUDIT_LOG_QUERY_END_TIME_DESCRIPTION)
58 84 @RequestParam(required = false) Long endTime,
  85 + @ApiParam(value = AUDIT_LOG_QUERY_ACTION_TYPES_DESCRIPTION)
59 86 @RequestParam(name = "actionTypes", required = false) String actionTypesStr) throws ThingsboardException {
60 87 try {
61 88 checkParameter("CustomerId", strCustomerId);
... ... @@ -68,18 +95,32 @@ public class AuditLogController extends BaseController {
68 95 }
69 96 }
70 97
  98 + @ApiOperation(value = "Get audit logs by user id (getAuditLogsByUserId)",
  99 + notes = "Returns a page of audit logs related to the actions of targeted user. " +
  100 + "For example, RPC call to a particular device, or alarm acknowledgment for a specific device, etc. " +
  101 + PAGE_DATA_PARAMETERS + ADMINISTRATOR_AUTHORITY_ONLY,
  102 + produces = MediaType.APPLICATION_JSON_VALUE)
71 103 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
72 104 @RequestMapping(value = "/audit/logs/user/{userId}", params = {"pageSize", "page"}, method = RequestMethod.GET)
73 105 @ResponseBody
74 106 public PageData<AuditLog> getAuditLogsByUserId(
  107 + @ApiParam(value = USER_ID_PARAM_DESCRIPTION)
75 108 @PathVariable("userId") String strUserId,
  109 + @ApiParam(value = PAGE_SIZE_DESCRIPTION)
76 110 @RequestParam int pageSize,
  111 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
77 112 @RequestParam int page,
  113 + @ApiParam(value = AUDIT_LOG_TEXT_SEARCH_DESCRIPTION)
78 114 @RequestParam(required = false) String textSearch,
  115 + @ApiParam(value = AUDIT_LOG_SORT_PROPERTY_DESCRIPTION, allowableValues = AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES)
79 116 @RequestParam(required = false) String sortProperty,
  117 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
80 118 @RequestParam(required = false) String sortOrder,
  119 + @ApiParam(value = AUDIT_LOG_QUERY_START_TIME_DESCRIPTION)
81 120 @RequestParam(required = false) Long startTime,
  121 + @ApiParam(value = AUDIT_LOG_QUERY_END_TIME_DESCRIPTION)
82 122 @RequestParam(required = false) Long endTime,
  123 + @ApiParam(value = AUDIT_LOG_QUERY_ACTION_TYPES_DESCRIPTION)
83 124 @RequestParam(name = "actionTypes", required = false) String actionTypesStr) throws ThingsboardException {
84 125 try {
85 126 checkParameter("UserId", strUserId);
... ... @@ -92,19 +133,35 @@ public class AuditLogController extends BaseController {
92 133 }
93 134 }
94 135
  136 + @ApiOperation(value = "Get audit logs by entity id (getAuditLogsByEntityId)",
  137 + notes = "Returns a page of audit logs related to the actions on the targeted entity. " +
  138 + "Basically, this API call is used to get the full lifecycle of some specific entity. " +
  139 + "For example to see when a device was created, updated, assigned to some customer, or even deleted from the system. " +
  140 + PAGE_DATA_PARAMETERS + ADMINISTRATOR_AUTHORITY_ONLY,
  141 + produces = MediaType.APPLICATION_JSON_VALUE)
95 142 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
96 143 @RequestMapping(value = "/audit/logs/entity/{entityType}/{entityId}", params = {"pageSize", "page"}, method = RequestMethod.GET)
97 144 @ResponseBody
98 145 public PageData<AuditLog> getAuditLogsByEntityId(
  146 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION)
99 147 @PathVariable("entityType") String strEntityType,
  148 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION)
100 149 @PathVariable("entityId") String strEntityId,
  150 + @ApiParam(value = PAGE_SIZE_DESCRIPTION)
101 151 @RequestParam int pageSize,
  152 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
102 153 @RequestParam int page,
  154 + @ApiParam(value = AUDIT_LOG_TEXT_SEARCH_DESCRIPTION)
103 155 @RequestParam(required = false) String textSearch,
  156 + @ApiParam(value = AUDIT_LOG_SORT_PROPERTY_DESCRIPTION, allowableValues = AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES)
104 157 @RequestParam(required = false) String sortProperty,
  158 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
105 159 @RequestParam(required = false) String sortOrder,
  160 + @ApiParam(value = AUDIT_LOG_QUERY_START_TIME_DESCRIPTION)
106 161 @RequestParam(required = false) Long startTime,
  162 + @ApiParam(value = AUDIT_LOG_QUERY_END_TIME_DESCRIPTION)
107 163 @RequestParam(required = false) Long endTime,
  164 + @ApiParam(value = AUDIT_LOG_QUERY_ACTION_TYPES_DESCRIPTION)
108 165 @RequestParam(name = "actionTypes", required = false) String actionTypesStr) throws ThingsboardException {
109 166 try {
110 167 checkParameter("EntityId", strEntityId);
... ... @@ -118,17 +175,29 @@ public class AuditLogController extends BaseController {
118 175 }
119 176 }
120 177
  178 + @ApiOperation(value = "Get all audit logs (getAuditLogs)",
  179 + notes = "Returns a page of audit logs related to all entities in the scope of the current user's Tenant. " +
  180 + PAGE_DATA_PARAMETERS + ADMINISTRATOR_AUTHORITY_ONLY,
  181 + produces = MediaType.APPLICATION_JSON_VALUE)
121 182 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
122 183 @RequestMapping(value = "/audit/logs", params = {"pageSize", "page"}, method = RequestMethod.GET)
123 184 @ResponseBody
124 185 public PageData<AuditLog> getAuditLogs(
  186 + @ApiParam(value = PAGE_SIZE_DESCRIPTION)
125 187 @RequestParam int pageSize,
  188 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
126 189 @RequestParam int page,
  190 + @ApiParam(value = AUDIT_LOG_TEXT_SEARCH_DESCRIPTION)
127 191 @RequestParam(required = false) String textSearch,
  192 + @ApiParam(value = AUDIT_LOG_SORT_PROPERTY_DESCRIPTION, allowableValues = AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES)
128 193 @RequestParam(required = false) String sortProperty,
  194 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
129 195 @RequestParam(required = false) String sortOrder,
  196 + @ApiParam(value = AUDIT_LOG_QUERY_START_TIME_DESCRIPTION)
130 197 @RequestParam(required = false) Long startTime,
  198 + @ApiParam(value = AUDIT_LOG_QUERY_END_TIME_DESCRIPTION)
131 199 @RequestParam(required = false) Long endTime,
  200 + @ApiParam(value = AUDIT_LOG_QUERY_ACTION_TYPES_DESCRIPTION)
132 201 @RequestParam(name = "actionTypes", required = false) String actionTypesStr) throws ThingsboardException {
133 202 try {
134 203 TenantId tenantId = getCurrentUser().getTenantId();
... ...
... ... @@ -169,63 +169,69 @@ public abstract class BaseController {
169 169 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
170 170 public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
171 171 public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
  172 + public static final String USER_ID_PARAM_DESCRIPTION = "A string value representing the user id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
172 173 public static final String ASSET_ID_PARAM_DESCRIPTION = "A string value representing the asset id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
173 174 public static final String ALARM_ID_PARAM_DESCRIPTION = "A string value representing the alarm id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
174 175 public static final String ENTITY_ID_PARAM_DESCRIPTION = "A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
175 176 public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'";
176 177 public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
177 178
178   - protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
179   - protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
180   - protected final String DEVICE_TYPE_DESCRIPTION = "Device type as the name of the device profile";
181   - protected final String ASSET_TYPE_DESCRIPTION = "Asset type";
182   - protected final String EDGE_TYPE_DESCRIPTION = "A string value representing the edge type. For example, 'default'";
183   -
184   - protected final String ASSET_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the asset name.";
185   - protected final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title.";
186   - protected final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name.";
187   - protected final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title.";
188   - protected final String EDGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge name.";
189   - protected final String EVENT_TEXT_SEARCH_DESCRIPTION = "The value is not used in searching.";
190   - protected final String SORT_PROPERTY_DESCRIPTION = "Property of entity to sort by";
191   - protected final String DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title";
192   - protected final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city";
193   - protected final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle";
194   - protected final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
195   - protected final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status";
196   - protected final String EVENT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, id";
197   - protected final String EDGE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
198   - protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESC (DESCENDING)";
199   - protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC";
200   - protected final String DEVICE_INFO_DESCRIPTION = "Device Info is an extension of the default Device object that contains information about the assigned customer name and device profile name. ";
201   - protected final String ASSET_INFO_DESCRIPTION = "Asset Info is an extension of the default Asset object that contains information about the assigned customer name. ";
202   - protected final String ALARM_INFO_DESCRIPTION = "Alarm Info is an extension of the default Alarm object that also contains name of the alarm originator.";
203   - protected final String RELATION_INFO_DESCRIPTION = "Relation Info is an extension of the default Relation object that contains information about the 'from' and 'to' entity names. ";
204   - protected final String EDGE_INFO_DESCRIPTION = "Edge Info is an extension of the default Edge object that contains information about the assigned customer name. ";
205   -
206   - protected final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name.";
207   - protected final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name.";
208   -
209   - protected final String EVENT_START_TIME_DESCRIPTION = "Timestamp. Events with creation time before it won't be queried.";
210   - protected final String EVENT_END_TIME_DESCRIPTION = "Timestamp. Events with creation time after it won't be queried.";
211   -
212   - protected final String MARKDOWN_CODE_BLOCK_START = "```json\n";
213   - protected final String MARKDOWN_CODE_BLOCK_END = "\n```";
214   - protected final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"ERROR\", \"server\": \"ip-172-31-24-152\", " +
  179 +
  180 + protected static final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
  181 + protected static final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
  182 + protected static final String DEVICE_TYPE_DESCRIPTION = "Device type as the name of the device profile";
  183 + protected static final String ASSET_TYPE_DESCRIPTION = "Asset type";
  184 + protected static final String EDGE_TYPE_DESCRIPTION = "A string value representing the edge type. For example, 'default'";
  185 +
  186 + protected static final String ASSET_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the asset name.";
  187 + protected static final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title.";
  188 + protected static final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name.";
  189 + protected static final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title.";
  190 + protected static final String EDGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge name.";
  191 + protected static final String EVENT_TEXT_SEARCH_DESCRIPTION = "The value is not used in searching.";
  192 + protected static final String AUDIT_LOG_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on one of the next properties: entityType, entityName, userName, actionType, actionStatus.";
  193 + protected static final String SORT_PROPERTY_DESCRIPTION = "Property of entity to sort by";
  194 + protected static final String DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title";
  195 + protected static final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city";
  196 + protected static final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle";
  197 + protected static final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
  198 + protected static final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status";
  199 + protected static final String EVENT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, id";
  200 + protected static final String EDGE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
  201 + protected static final String AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, entityType, entityName, userName, actionType, actionStatus";
  202 + protected static final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESC (DESCENDING)";
  203 + protected static final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC";
  204 + protected static final String DEVICE_INFO_DESCRIPTION = "Device Info is an extension of the default Device object that contains information about the assigned customer name and device profile name. ";
  205 + protected static final String ASSET_INFO_DESCRIPTION = "Asset Info is an extension of the default Asset object that contains information about the assigned customer name. ";
  206 + protected static final String ALARM_INFO_DESCRIPTION = "Alarm Info is an extension of the default Alarm object that also contains name of the alarm originator.";
  207 + protected static final String RELATION_INFO_DESCRIPTION = "Relation Info is an extension of the default Relation object that contains information about the 'from' and 'to' entity names. ";
  208 + protected static final String EDGE_INFO_DESCRIPTION = "Edge Info is an extension of the default Edge object that contains information about the assigned customer name. ";
  209 +
  210 + protected static final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name.";
  211 + protected static final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name.";
  212 +
  213 + protected static final String EVENT_START_TIME_DESCRIPTION = "Timestamp. Events with creation time before it won't be queried.";
  214 + protected static final String EVENT_END_TIME_DESCRIPTION = "Timestamp. Events with creation time after it won't be queried.";
  215 +
  216 + protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n";
  217 + protected static final String MARKDOWN_CODE_BLOCK_END = "\n```";
  218 + protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"ERROR\", \"server\": \"ip-172-31-24-152\", " +
215 219 "\"method\": \"onClusterEventMsg\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END;
216   - protected final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"LC_EVENT\", \"server\": \"ip-172-31-24-152\", \"event\":" +
  220 + protected static final String EVENT_LC_EVENT_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"LC_EVENT\", \"server\": \"ip-172-31-24-152\", \"event\":" +
217 221 " \"STARTED\", \"status\": \"Success\", \"error\": \"Error Message\" }" + MARKDOWN_CODE_BLOCK_END;
218   - protected 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;
219   - protected final String DEBUG_FILTER_OBJ = "\"msgDirectionType\": \"IN\", \"server\": \"ip-172-31-24-152\", \"dataSearch\": \"humidity\", " +
  222 + 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;
  223 + protected static final String DEBUG_FILTER_OBJ = "\"msgDirectionType\": \"IN\", \"server\": \"ip-172-31-24-152\", \"dataSearch\": \"humidity\", " +
220 224 "\"metadataSearch\": \"deviceName\", \"entityName\": \"DEVICE\", \"relationType\": \"Success\"," +
221 225 " \"entityId\": \"de9d54a0-2b7a-11ec-a3cc-23386423d98f\", \"msgType\": \"POST_TELEMETRY_REQUEST\"," +
222 226 " \"isError\": \"false\", \"error\": \"Error Message\" }";
223   - protected final String EVENT_DEBUG_RULE_NODE_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"DEBUG_RULE_NODE\"," + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END;
224   - protected final String EVENT_DEBUG_RULE_CHAIN_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"DEBUG_RULE_CHAIN\"," + DEBUG_FILTER_OBJ + MARKDOWN_CODE_BLOCK_END;
  227 + 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;
  228 + 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;
225 229
226 230 protected static final String RELATION_TYPE_PARAM_DESCRIPTION = "A string value representing relation type between entities. For example, 'Contains', 'Manages'. It can be any string value.";
227 231 protected static final String RELATION_TYPE_GROUP_PARAM_DESCRIPTION = "A string value representing relation type group. For example, 'COMMON'";
228 232
  233 + protected static final String ADMINISTRATOR_AUTHORITY_ONLY = "Available for users with 'Tenant Administrator' authority only.";
  234 +
229 235 public static final String INCORRECT_TENANT_ID = "Incorrect tenantId ";
230 236 protected static final String DEFAULT_DASHBOARD = "defaultDashboardId";
231 237 protected static final String HOME_DASHBOARD = "homeDashboardId";
... ...
... ... @@ -212,7 +212,7 @@ public class CustomerController extends BaseController {
212 212 }
213 213
214 214 @ApiOperation(value = "Get Tenant Customer by Customer title (getTenantCustomer)",
215   - notes = "Get the Customer using Customer Title. Available for users with 'Tenant Administrator' authority only.")
  215 + notes = "Get the Customer using Customer Title. " + ADMINISTRATOR_AUTHORITY_ONLY)
216 216 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
217 217 @RequestMapping(value = "/tenant/customers", params = {"customerTitle"}, method = RequestMethod.GET)
218 218 @ResponseBody
... ...
... ... @@ -16,24 +16,37 @@
16 16 package org.thingsboard.server.common.data.audit;
17 17
18 18 import com.fasterxml.jackson.databind.JsonNode;
  19 +import io.swagger.annotations.ApiModel;
  20 +import io.swagger.annotations.ApiModelProperty;
19 21 import lombok.Data;
20 22 import lombok.EqualsAndHashCode;
21 23 import org.thingsboard.server.common.data.BaseData;
22 24 import org.thingsboard.server.common.data.id.*;
23 25
  26 +@ApiModel
24 27 @EqualsAndHashCode(callSuper = true)
25 28 @Data
26 29 public class AuditLog extends BaseData<AuditLogId> {
27 30
  31 + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id", readOnly = true)
28 32 private TenantId tenantId;
  33 + @ApiModelProperty(position = 4, value = "JSON object with Customer Id", readOnly = true)
29 34 private CustomerId customerId;
  35 + @ApiModelProperty(position = 5, value = "JSON object with Entity id", readOnly = true)
30 36 private EntityId entityId;
  37 + @ApiModelProperty(position = 6, value = "Name of the logged entity", example = "Thermometer", readOnly = true)
31 38 private String entityName;
  39 + @ApiModelProperty(position = 7, value = "JSON object with User id.", readOnly = true)
32 40 private UserId userId;
  41 + @ApiModelProperty(position = 8, value = "Unique user name(email) of the user that performed some action on logged entity", example = "tenant@thingsboard.org", readOnly = true)
33 42 private String userName;
  43 + @ApiModelProperty(position = 9, value = "String represented Action type", example = "ADDED", readOnly = true)
34 44 private ActionType actionType;
  45 + @ApiModelProperty(position = 10, value = "JsonNode represented action data", readOnly = true)
35 46 private JsonNode actionData;
  47 + @ApiModelProperty(position = 11, value = "String represented Action status", example = "SUCCESS", allowableValues = "SUCCESS,FAILURE", readOnly = true)
36 48 private ActionStatus actionStatus;
  49 + @ApiModelProperty(position = 12, value = "Failure action details info. An empty string in case of action status type 'SUCCESS', otherwise includes stack trace of the caused exception.", readOnly = true)
37 50 private String actionFailureDetails;
38 51
39 52 public AuditLog() {
... ... @@ -57,4 +70,17 @@ public class AuditLog extends BaseData<AuditLogId> {
57 70 this.actionStatus = auditLog.getActionStatus();
58 71 this.actionFailureDetails = auditLog.getActionFailureDetails();
59 72 }
  73 +
  74 + @ApiModelProperty(position = 2, value = "Timestamp of the auditLog creation, in milliseconds", example = "1609459200000", readOnly = true)
  75 + @Override
  76 + public long getCreatedTime() {
  77 + return super.getCreatedTime();
  78 + }
  79 +
  80 + @ApiModelProperty(position = 1, value = "JSON object with the auditLog Id")
  81 + @Override
  82 + public AuditLogId getId() {
  83 + return super.getId();
  84 + }
  85 +
60 86 }
... ...