|
@@ -17,9 +17,12 @@ package org.thingsboard.server.controller; |
|
@@ -17,9 +17,12 @@ package org.thingsboard.server.controller; |
17
|
|
17
|
|
18
|
import com.fasterxml.jackson.databind.JsonNode;
|
18
|
import com.fasterxml.jackson.databind.JsonNode;
|
19
|
import com.google.common.util.concurrent.ListenableFuture;
|
19
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
|
20
|
+import io.swagger.annotations.ApiOperation;
|
|
|
21
|
+import io.swagger.annotations.ApiParam;
|
20
|
import lombok.RequiredArgsConstructor;
|
22
|
import lombok.RequiredArgsConstructor;
|
21
|
import lombok.extern.slf4j.Slf4j;
|
23
|
import lombok.extern.slf4j.Slf4j;
|
22
|
import org.springframework.http.HttpStatus;
|
24
|
import org.springframework.http.HttpStatus;
|
|
|
25
|
+import org.springframework.http.MediaType;
|
23
|
import org.springframework.http.ResponseEntity;
|
26
|
import org.springframework.http.ResponseEntity;
|
24
|
import org.springframework.security.access.prepost.PreAuthorize;
|
27
|
import org.springframework.security.access.prepost.PreAuthorize;
|
25
|
import org.springframework.web.bind.annotation.PathVariable;
|
28
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -75,7 +78,11 @@ public class EdgeController extends BaseController { |
|
@@ -75,7 +78,11 @@ public class EdgeController extends BaseController { |
75
|
private final EdgeBulkImportService edgeBulkImportService;
|
78
|
private final EdgeBulkImportService edgeBulkImportService;
|
76
|
|
79
|
|
77
|
public static final String EDGE_ID = "edgeId";
|
80
|
public static final String EDGE_ID = "edgeId";
|
|
|
81
|
+ public static final String EDGE_SECURITY_CHECK = "If the user has the authority of 'Tenant Administrator', the server checks that the edge is owned by the same tenant. " +
|
|
|
82
|
+ "If the user has the authority of 'Customer User', the server checks that the edge is assigned to the same customer.";
|
78
|
|
83
|
|
|
|
84
|
+ @ApiOperation(value = "Is edges support enabled (isEdgesSupportEnabled)",
|
|
|
85
|
+ notes = "Returns 'true' if edges support enabled on server, 'false' - otherwise.")
|
79
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
86
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
80
|
@RequestMapping(value = "/edges/enabled", method = RequestMethod.GET)
|
87
|
@RequestMapping(value = "/edges/enabled", method = RequestMethod.GET)
|
81
|
@ResponseBody
|
88
|
@ResponseBody
|
|
@@ -83,10 +90,14 @@ public class EdgeController extends BaseController { |
|
@@ -83,10 +90,14 @@ public class EdgeController extends BaseController { |
83
|
return edgesEnabled;
|
90
|
return edgesEnabled;
|
84
|
}
|
91
|
}
|
85
|
|
92
|
|
|
|
93
|
+ @ApiOperation(value = "Get Edge (getEdgeById)",
|
|
|
94
|
+ notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK,
|
|
|
95
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
86
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
96
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
87
|
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
|
97
|
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
|
88
|
@ResponseBody
|
98
|
@ResponseBody
|
89
|
- public Edge getEdgeById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
99
|
+ public Edge getEdgeById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
100
|
+ @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
90
|
checkParameter(EDGE_ID, strEdgeId);
|
101
|
checkParameter(EDGE_ID, strEdgeId);
|
91
|
try {
|
102
|
try {
|
92
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
103
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
|
@@ -100,10 +111,14 @@ public class EdgeController extends BaseController { |
|
@@ -100,10 +111,14 @@ public class EdgeController extends BaseController { |
100
|
}
|
111
|
}
|
101
|
}
|
112
|
}
|
102
|
|
113
|
|
|
|
114
|
+ @ApiOperation(value = "Get Edge Info (getEdgeInfoById)",
|
|
|
115
|
+ notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK,
|
|
|
116
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
103
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
117
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
104
|
@RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET)
|
118
|
@RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET)
|
105
|
@ResponseBody
|
119
|
@ResponseBody
|
106
|
- public EdgeInfo getEdgeInfoById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
120
|
+ public EdgeInfo getEdgeInfoById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
121
|
+ @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
107
|
checkParameter(EDGE_ID, strEdgeId);
|
122
|
checkParameter(EDGE_ID, strEdgeId);
|
108
|
try {
|
123
|
try {
|
109
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
124
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
|
@@ -117,10 +132,18 @@ public class EdgeController extends BaseController { |
|
@@ -117,10 +132,18 @@ public class EdgeController extends BaseController { |
117
|
}
|
132
|
}
|
118
|
}
|
133
|
}
|
119
|
|
134
|
|
|
|
135
|
+ @ApiOperation(value = "Create Or Update Edge (saveEdge)",
|
|
|
136
|
+ notes = "Create or update the Edge. When creating edge, platform generates Edge Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
|
|
|
137
|
+ "The newly created edge id will be present in the response. " +
|
|
|
138
|
+ "Specify existing Edge id to update the edge. " +
|
|
|
139
|
+ "Referencing non-existing Edge Id will cause 'Not Found' error." +
|
|
|
140
|
+ "\n\nEdge name is unique in the scope of tenant. Use unique identifiers like MAC or IMEI for the edge names and non-unique 'label' field for user-friendly visualization purposes.",
|
|
|
141
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
120
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
142
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
121
|
@RequestMapping(value = "/edge", method = RequestMethod.POST)
|
143
|
@RequestMapping(value = "/edge", method = RequestMethod.POST)
|
122
|
@ResponseBody
|
144
|
@ResponseBody
|
123
|
- public Edge saveEdge(@RequestBody Edge edge) throws ThingsboardException {
|
145
|
+ public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.", required = true)
|
|
|
146
|
+ @RequestBody Edge edge) throws ThingsboardException {
|
124
|
try {
|
147
|
try {
|
125
|
TenantId tenantId = getCurrentUser().getTenantId();
|
148
|
TenantId tenantId = getCurrentUser().getTenantId();
|
126
|
edge.setTenantId(tenantId);
|
149
|
edge.setTenantId(tenantId);
|
|
@@ -163,10 +186,13 @@ public class EdgeController extends BaseController { |
|
@@ -163,10 +186,13 @@ public class EdgeController extends BaseController { |
163
|
logEntityAction(edge.getId(), edge, null, updated ? ActionType.UPDATED : ActionType.ADDED, null);
|
186
|
logEntityAction(edge.getId(), edge, null, updated ? ActionType.UPDATED : ActionType.ADDED, null);
|
164
|
}
|
187
|
}
|
165
|
|
188
|
|
|
|
189
|
+ @ApiOperation(value = "Delete edge (deleteEdge)",
|
|
|
190
|
+ notes = "Deletes the edge. Referencing non-existing edge Id will cause an error.")
|
166
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
191
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
167
|
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE)
|
192
|
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE)
|
168
|
@ResponseStatus(value = HttpStatus.OK)
|
193
|
@ResponseStatus(value = HttpStatus.OK)
|
169
|
- public void deleteEdge(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
194
|
+ public void deleteEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
195
|
+ @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
170
|
checkParameter(EDGE_ID, strEdgeId);
|
196
|
checkParameter(EDGE_ID, strEdgeId);
|
171
|
try {
|
197
|
try {
|
172
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
198
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
|
@@ -191,13 +217,21 @@ public class EdgeController extends BaseController { |
|
@@ -191,13 +217,21 @@ public class EdgeController extends BaseController { |
191
|
}
|
217
|
}
|
192
|
}
|
218
|
}
|
193
|
|
219
|
|
|
|
220
|
+ @ApiOperation(value = "Get Tenant Edges (getEdges)",
|
|
|
221
|
+ notes = "Returns a page of edges owned by tenant. " +
|
|
|
222
|
+ PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
|
194
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
223
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
195
|
@RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
224
|
@RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
196
|
@ResponseBody
|
225
|
@ResponseBody
|
197
|
- public PageData<Edge> getEdges(@RequestParam int pageSize,
|
226
|
+ public PageData<Edge> getEdges(@ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
|
|
227
|
+ @RequestParam int pageSize,
|
|
|
228
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
198
|
@RequestParam int page,
|
229
|
@RequestParam int page,
|
|
|
230
|
+ @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
199
|
@RequestParam(required = false) String textSearch,
|
231
|
@RequestParam(required = false) String textSearch,
|
|
|
232
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
200
|
@RequestParam(required = false) String sortProperty,
|
233
|
@RequestParam(required = false) String sortProperty,
|
|
|
234
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
201
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
235
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
202
|
try {
|
236
|
try {
|
203
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
237
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
|
@@ -208,10 +242,15 @@ public class EdgeController extends BaseController { |
|
@@ -208,10 +242,15 @@ public class EdgeController extends BaseController { |
208
|
}
|
242
|
}
|
209
|
}
|
243
|
}
|
210
|
|
244
|
|
|
|
245
|
+ @ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)",
|
|
|
246
|
+ notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards.",
|
|
|
247
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
211
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
248
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
212
|
@RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST)
|
249
|
@RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST)
|
213
|
@ResponseBody
|
250
|
@ResponseBody
|
214
|
- public Edge assignEdgeToCustomer(@PathVariable("customerId") String strCustomerId,
|
251
|
+ public Edge assignEdgeToCustomer(@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
|
|
|
252
|
+ @PathVariable("customerId") String strCustomerId,
|
|
|
253
|
+ @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
215
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
254
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
216
|
checkParameter("customerId", strCustomerId);
|
255
|
checkParameter("customerId", strCustomerId);
|
217
|
checkParameter(EDGE_ID, strEdgeId);
|
256
|
checkParameter(EDGE_ID, strEdgeId);
|
|
@@ -243,10 +282,14 @@ public class EdgeController extends BaseController { |
|
@@ -243,10 +282,14 @@ public class EdgeController extends BaseController { |
243
|
}
|
282
|
}
|
244
|
}
|
283
|
}
|
245
|
|
284
|
|
|
|
285
|
+ @ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)",
|
|
|
286
|
+ notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards.",
|
|
|
287
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
246
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
288
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
247
|
@RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE)
|
289
|
@RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE)
|
248
|
@ResponseBody
|
290
|
@ResponseBody
|
249
|
- public Edge unassignEdgeFromCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
291
|
+ public Edge unassignEdgeFromCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
292
|
+ @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
250
|
checkParameter(EDGE_ID, strEdgeId);
|
293
|
checkParameter(EDGE_ID, strEdgeId);
|
251
|
try {
|
294
|
try {
|
252
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
295
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
|
@@ -277,10 +320,16 @@ public class EdgeController extends BaseController { |
|
@@ -277,10 +320,16 @@ public class EdgeController extends BaseController { |
277
|
}
|
320
|
}
|
278
|
}
|
321
|
}
|
279
|
|
322
|
|
|
|
323
|
+ @ApiOperation(value = "Make edge publicly available (assignEdgeToPublicCustomer)",
|
|
|
324
|
+ notes = "Edge will be available for non-authorized (not logged-in) users. " +
|
|
|
325
|
+ "This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
|
|
|
326
|
+ "However, users that are logged-in and belong to different tenant will not be able to access the edge.",
|
|
|
327
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
280
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
328
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
281
|
@RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST)
|
329
|
@RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST)
|
282
|
@ResponseBody
|
330
|
@ResponseBody
|
283
|
- public Edge assignEdgeToPublicCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
331
|
+ public Edge assignEdgeToPublicCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
332
|
+ @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
284
|
checkParameter(EDGE_ID, strEdgeId);
|
333
|
checkParameter(EDGE_ID, strEdgeId);
|
285
|
try {
|
334
|
try {
|
286
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
335
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
|
@@ -304,15 +353,24 @@ public class EdgeController extends BaseController { |
|
@@ -304,15 +353,24 @@ public class EdgeController extends BaseController { |
304
|
}
|
353
|
}
|
305
|
}
|
354
|
}
|
306
|
|
355
|
|
|
|
356
|
+ @ApiOperation(value = "Get Tenant Edges (getTenantEdges)",
|
|
|
357
|
+ notes = "Returns a page of edges owned by tenant. " +
|
|
|
358
|
+ PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
|
307
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
359
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
308
|
@RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
360
|
@RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
309
|
@ResponseBody
|
361
|
@ResponseBody
|
310
|
public PageData<Edge> getTenantEdges(
|
362
|
public PageData<Edge> getTenantEdges(
|
|
|
363
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
311
|
@RequestParam int pageSize,
|
364
|
@RequestParam int pageSize,
|
|
|
365
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
312
|
@RequestParam int page,
|
366
|
@RequestParam int page,
|
|
|
367
|
+ @ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
313
|
@RequestParam(required = false) String type,
|
368
|
@RequestParam(required = false) String type,
|
|
|
369
|
+ @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
314
|
@RequestParam(required = false) String textSearch,
|
370
|
@RequestParam(required = false) String textSearch,
|
|
|
371
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
315
|
@RequestParam(required = false) String sortProperty,
|
372
|
@RequestParam(required = false) String sortProperty,
|
|
|
373
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
316
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
374
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
317
|
try {
|
375
|
try {
|
318
|
TenantId tenantId = getCurrentUser().getTenantId();
|
376
|
TenantId tenantId = getCurrentUser().getTenantId();
|
|
@@ -327,15 +385,25 @@ public class EdgeController extends BaseController { |
|
@@ -327,15 +385,25 @@ public class EdgeController extends BaseController { |
327
|
}
|
385
|
}
|
328
|
}
|
386
|
}
|
329
|
|
387
|
|
|
|
388
|
+ @ApiOperation(value = "Get Tenant Edge Infos (getTenantEdgeInfos)",
|
|
|
389
|
+ notes = "Returns a page of edges info objects owned by tenant. " +
|
|
|
390
|
+ PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION,
|
|
|
391
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
330
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
392
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
331
|
@RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
393
|
@RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
332
|
@ResponseBody
|
394
|
@ResponseBody
|
333
|
public PageData<EdgeInfo> getTenantEdgeInfos(
|
395
|
public PageData<EdgeInfo> getTenantEdgeInfos(
|
|
|
396
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
334
|
@RequestParam int pageSize,
|
397
|
@RequestParam int pageSize,
|
|
|
398
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
335
|
@RequestParam int page,
|
399
|
@RequestParam int page,
|
|
|
400
|
+ @ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
336
|
@RequestParam(required = false) String type,
|
401
|
@RequestParam(required = false) String type,
|
|
|
402
|
+ @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
337
|
@RequestParam(required = false) String textSearch,
|
403
|
@RequestParam(required = false) String textSearch,
|
|
|
404
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
338
|
@RequestParam(required = false) String sortProperty,
|
405
|
@RequestParam(required = false) String sortProperty,
|
|
|
406
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
339
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
407
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
340
|
try {
|
408
|
try {
|
341
|
TenantId tenantId = getCurrentUser().getTenantId();
|
409
|
TenantId tenantId = getCurrentUser().getTenantId();
|
|
@@ -350,10 +418,15 @@ public class EdgeController extends BaseController { |
|
@@ -350,10 +418,15 @@ public class EdgeController extends BaseController { |
350
|
}
|
418
|
}
|
351
|
}
|
419
|
}
|
352
|
|
420
|
|
|
|
421
|
+ @ApiOperation(value = "Get Tenant Edge (getTenantEdge)",
|
|
|
422
|
+ notes = "Requested edge must be owned by tenant or customer that the user belongs to. " +
|
|
|
423
|
+ "Edge name is an unique property of edge. So it can be used to identify the edge.",
|
|
|
424
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
353
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
425
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
354
|
@RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET)
|
426
|
@RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET)
|
355
|
@ResponseBody
|
427
|
@ResponseBody
|
356
|
- public Edge getTenantEdge(@RequestParam String edgeName) throws ThingsboardException {
|
428
|
+ public Edge getTenantEdge(@ApiParam(value = "Unique name of the edge", required = true)
|
|
|
429
|
+ @RequestParam String edgeName) throws ThingsboardException {
|
357
|
try {
|
430
|
try {
|
358
|
TenantId tenantId = getCurrentUser().getTenantId();
|
431
|
TenantId tenantId = getCurrentUser().getTenantId();
|
359
|
return checkNotNull(edgeService.findEdgeByTenantIdAndName(tenantId, edgeName));
|
432
|
return checkNotNull(edgeService.findEdgeByTenantIdAndName(tenantId, edgeName));
|
|
@@ -362,10 +435,16 @@ public class EdgeController extends BaseController { |
|
@@ -362,10 +435,16 @@ public class EdgeController extends BaseController { |
362
|
}
|
435
|
}
|
363
|
}
|
436
|
}
|
364
|
|
437
|
|
|
|
438
|
+ @ApiOperation(value = "Set root rule chain for provided edge (setRootRuleChain)",
|
|
|
439
|
+ notes = "Change root rule chain of the edge to the new provided rule chain. \n" +
|
|
|
440
|
+ "This operation will send a notification to update root rule chain on remote edge service.",
|
|
|
441
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
365
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
442
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
366
|
@RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
|
443
|
@RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
|
367
|
@ResponseBody
|
444
|
@ResponseBody
|
368
|
- public Edge setRootRuleChain(@PathVariable(EDGE_ID) String strEdgeId,
|
445
|
+ public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
446
|
+ @PathVariable(EDGE_ID) String strEdgeId,
|
|
|
447
|
+ @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true)
|
369
|
@PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException {
|
448
|
@PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException {
|
370
|
checkParameter(EDGE_ID, strEdgeId);
|
449
|
checkParameter(EDGE_ID, strEdgeId);
|
371
|
checkParameter("ruleChainId", strRuleChainId);
|
450
|
checkParameter("ruleChainId", strRuleChainId);
|
|
@@ -394,16 +473,26 @@ public class EdgeController extends BaseController { |
|
@@ -394,16 +473,26 @@ public class EdgeController extends BaseController { |
394
|
}
|
473
|
}
|
395
|
}
|
474
|
}
|
396
|
|
475
|
|
|
|
476
|
+ @ApiOperation(value = "Get Customer Edges (getCustomerEdges)",
|
|
|
477
|
+ notes = "Returns a page of edges objects assigned to customer. " +
|
|
|
478
|
+ PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
|
397
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
479
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
398
|
@RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
480
|
@RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
399
|
@ResponseBody
|
481
|
@ResponseBody
|
400
|
public PageData<Edge> getCustomerEdges(
|
482
|
public PageData<Edge> getCustomerEdges(
|
|
|
483
|
+ @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
401
|
@PathVariable("customerId") String strCustomerId,
|
484
|
@PathVariable("customerId") String strCustomerId,
|
|
|
485
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
402
|
@RequestParam int pageSize,
|
486
|
@RequestParam int pageSize,
|
|
|
487
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
403
|
@RequestParam int page,
|
488
|
@RequestParam int page,
|
|
|
489
|
+ @ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
404
|
@RequestParam(required = false) String type,
|
490
|
@RequestParam(required = false) String type,
|
|
|
491
|
+ @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
405
|
@RequestParam(required = false) String textSearch,
|
492
|
@RequestParam(required = false) String textSearch,
|
|
|
493
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
406
|
@RequestParam(required = false) String sortProperty,
|
494
|
@RequestParam(required = false) String sortProperty,
|
|
|
495
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
407
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
496
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
408
|
checkParameter("customerId", strCustomerId);
|
497
|
checkParameter("customerId", strCustomerId);
|
409
|
try {
|
498
|
try {
|
|
@@ -429,16 +518,26 @@ public class EdgeController extends BaseController { |
|
@@ -429,16 +518,26 @@ public class EdgeController extends BaseController { |
429
|
}
|
518
|
}
|
430
|
}
|
519
|
}
|
431
|
|
520
|
|
|
|
521
|
+ @ApiOperation(value = "Get Customer Edge Infos (getCustomerEdgeInfos)",
|
|
|
522
|
+ notes = "Returns a page of edges info objects assigned to customer. " +
|
|
|
523
|
+ PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION, produces = MediaType.APPLICATION_JSON_VALUE)
|
432
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
524
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
433
|
@RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
525
|
@RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
434
|
@ResponseBody
|
526
|
@ResponseBody
|
435
|
public PageData<EdgeInfo> getCustomerEdgeInfos(
|
527
|
public PageData<EdgeInfo> getCustomerEdgeInfos(
|
|
|
528
|
+ @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
436
|
@PathVariable("customerId") String strCustomerId,
|
529
|
@PathVariable("customerId") String strCustomerId,
|
|
|
530
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
437
|
@RequestParam int pageSize,
|
531
|
@RequestParam int pageSize,
|
|
|
532
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
438
|
@RequestParam int page,
|
533
|
@RequestParam int page,
|
|
|
534
|
+ @ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
439
|
@RequestParam(required = false) String type,
|
535
|
@RequestParam(required = false) String type,
|
|
|
536
|
+ @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
440
|
@RequestParam(required = false) String textSearch,
|
537
|
@RequestParam(required = false) String textSearch,
|
|
|
538
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
|
441
|
@RequestParam(required = false) String sortProperty,
|
539
|
@RequestParam(required = false) String sortProperty,
|
|
|
540
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
442
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
541
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
443
|
checkParameter("customerId", strCustomerId);
|
542
|
checkParameter("customerId", strCustomerId);
|
444
|
try {
|
543
|
try {
|
|
@@ -464,10 +563,14 @@ public class EdgeController extends BaseController { |
|
@@ -464,10 +563,14 @@ public class EdgeController extends BaseController { |
464
|
}
|
563
|
}
|
465
|
}
|
564
|
}
|
466
|
|
565
|
|
|
|
566
|
+ @ApiOperation(value = "Get Edges By Ids (getEdgesByIds)",
|
|
|
567
|
+ notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request.",
|
|
|
568
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
467
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
569
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
468
|
@RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET)
|
570
|
@RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET)
|
469
|
@ResponseBody
|
571
|
@ResponseBody
|
470
|
public List<Edge> getEdgesByIds(
|
572
|
public List<Edge> getEdgesByIds(
|
|
|
573
|
+ @ApiParam(value = "A list of edges ids, separated by comma ','", required = true)
|
471
|
@RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException {
|
574
|
@RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException {
|
472
|
checkArrayParameter("edgeIds", strEdgeIds);
|
575
|
checkArrayParameter("edgeIds", strEdgeIds);
|
473
|
try {
|
576
|
try {
|
|
@@ -496,6 +599,11 @@ public class EdgeController extends BaseController { |
|
@@ -496,6 +599,11 @@ public class EdgeController extends BaseController { |
496
|
}
|
599
|
}
|
497
|
}
|
600
|
}
|
498
|
|
601
|
|
|
|
602
|
+ @ApiOperation(value = "Find related edges (findByQuery)",
|
|
|
603
|
+ notes = "Returns all edges that are related to the specific entity. " +
|
|
|
604
|
+ "The entity id, relation type, edge types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " +
|
|
|
605
|
+ "See 'Model' tab of the Parameters for more info.",
|
|
|
606
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
499
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
607
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
500
|
@RequestMapping(value = "/edges", method = RequestMethod.POST)
|
608
|
@RequestMapping(value = "/edges", method = RequestMethod.POST)
|
501
|
@ResponseBody
|
609
|
@ResponseBody
|
|
@@ -527,6 +635,9 @@ public class EdgeController extends BaseController { |
|
@@ -527,6 +635,9 @@ public class EdgeController extends BaseController { |
527
|
}
|
635
|
}
|
528
|
}
|
636
|
}
|
529
|
|
637
|
|
|
|
638
|
+ @ApiOperation(value = "Get Edge Types (getEdgeTypes)",
|
|
|
639
|
+ notes = "Returns a set of unique edge types based on edges that are either owned by the tenant or assigned to the customer which user is performing the request.",
|
|
|
640
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
530
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
641
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
531
|
@RequestMapping(value = "/edge/types", method = RequestMethod.GET)
|
642
|
@RequestMapping(value = "/edge/types", method = RequestMethod.GET)
|
532
|
@ResponseBody
|
643
|
@ResponseBody
|
|
@@ -541,9 +652,13 @@ public class EdgeController extends BaseController { |
|
@@ -541,9 +652,13 @@ public class EdgeController extends BaseController { |
541
|
}
|
652
|
}
|
542
|
}
|
653
|
}
|
543
|
|
654
|
|
|
|
655
|
+ @ApiOperation(value = "Sync edge (syncEdge)",
|
|
|
656
|
+ notes = "Starts synchronization process between edge and cloud. \n" +
|
|
|
657
|
+ "All entities that are assigned to particular edge are going to be send to remote edge service.")
|
544
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
658
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
545
|
@RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
|
659
|
@RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
|
546
|
- public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
660
|
+ public void syncEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
661
|
+ @PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
547
|
checkParameter("edgeId", strEdgeId);
|
662
|
checkParameter("edgeId", strEdgeId);
|
548
|
try {
|
663
|
try {
|
549
|
if (isEdgesEnabled()) {
|
664
|
if (isEdgesEnabled()) {
|
|
@@ -560,10 +675,13 @@ public class EdgeController extends BaseController { |
|
@@ -560,10 +675,13 @@ public class EdgeController extends BaseController { |
560
|
}
|
675
|
}
|
561
|
}
|
676
|
}
|
562
|
|
677
|
|
|
|
678
|
+ @ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)",
|
|
|
679
|
+ notes = "Returns list of rule chains ids that are not assigned to particular edge, but these rule chains are present in the already assigned rule chains to edge.")
|
563
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
680
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
564
|
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
|
681
|
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
|
565
|
@ResponseBody
|
682
|
@ResponseBody
|
566
|
- public String findMissingToRelatedRuleChains(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
683
|
+ public String findMissingToRelatedRuleChains(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
|
|
684
|
+ @PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
567
|
try {
|
685
|
try {
|
568
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
686
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
569
|
edgeId = checkNotNull(edgeId);
|
687
|
edgeId = checkNotNull(edgeId);
|
|
@@ -575,9 +693,12 @@ public class EdgeController extends BaseController { |
|
@@ -575,9 +693,12 @@ public class EdgeController extends BaseController { |
575
|
}
|
693
|
}
|
576
|
}
|
694
|
}
|
577
|
|
695
|
|
|
|
696
|
+ @ApiOperation(value = "Import the bulk of edges (processEdgesBulkImport)",
|
|
|
697
|
+ notes = "There's an ability to import the bulk of edges using the only .csv file.",
|
|
|
698
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
578
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
699
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
579
|
@PostMapping("/edge/bulk_import")
|
700
|
@PostMapping("/edge/bulk_import")
|
580
|
- public BulkImportResult<Edge> processEdgeBulkImport(@RequestBody BulkImportRequest request) throws Exception {
|
701
|
+ public BulkImportResult<Edge> processEdgesBulkImport(@RequestBody BulkImportRequest request) throws Exception {
|
581
|
SecurityUser user = getCurrentUser();
|
702
|
SecurityUser user = getCurrentUser();
|
582
|
RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(user.getTenantId());
|
703
|
RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(user.getTenantId());
|
583
|
if (edgeTemplateRootRuleChain == null) {
|
704
|
if (edgeTemplateRootRuleChain == null) {
|