Commit 1d87ad73c49b534529c8d0bb58a620d26171b443

Authored by Andrii Shvaika
1 parent 5285cec6

Swagger Device Controller

... ... @@ -97,6 +97,7 @@ import static org.thingsboard.server.controller.EdgeController.EDGE_ID;
97 97 @RequiredArgsConstructor
98 98 @Slf4j
99 99 public class DeviceController extends BaseController {
  100 + public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
100 101 private final DeviceBulkImportService deviceBulkImportService;
101 102
102 103 private static final String DEVICE_ID = "deviceId";
... ... @@ -235,10 +236,13 @@ public class DeviceController extends BaseController {
235 236 }
236 237 }
237 238
  239 + @ApiOperation(value = "Unassign device from customer (unassignDeviceFromCustomer)",
  240 + notes = "Clears assignment of the device to customer. Customer will not be able to query device afterwards.")
238 241 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
239 242 @RequestMapping(value = "/customer/device/{deviceId}", method = RequestMethod.DELETE)
240 243 @ResponseBody
241   - public Device unassignDeviceFromCustomer(@PathVariable(DEVICE_ID) String strDeviceId) throws ThingsboardException {
  244 + public Device unassignDeviceFromCustomer(@ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION)
  245 + @PathVariable(DEVICE_ID) String strDeviceId) throws ThingsboardException {
242 246 checkParameter(DEVICE_ID, strDeviceId);
243 247 try {
244 248 DeviceId deviceId = new DeviceId(toUUID(strDeviceId));
... ... @@ -266,10 +270,15 @@ public class DeviceController extends BaseController {
266 270 }
267 271 }
268 272
  273 + @ApiOperation(value = "Make device publicly available (assignDeviceToPublicCustomer)",
  274 + notes = "Device will be available for non-authorized (not logged-in) users. " +
  275 + "This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
  276 + "However, users that are logged-in and belong to different tenant will not be able to access the device.")
269 277 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
270 278 @RequestMapping(value = "/customer/public/device/{deviceId}", method = RequestMethod.POST)
271 279 @ResponseBody
272   - public Device assignDeviceToPublicCustomer(@PathVariable(DEVICE_ID) String strDeviceId) throws ThingsboardException {
  280 + public Device assignDeviceToPublicCustomer(@ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION)
  281 + @PathVariable(DEVICE_ID) String strDeviceId) throws ThingsboardException {
273 282 checkParameter(DEVICE_ID, strDeviceId);
274 283 try {
275 284 DeviceId deviceId = new DeviceId(toUUID(strDeviceId));
... ...