Commit 3103f596d58e3ea38a9f348c64061a57e3cb98c4

Authored by YevhenBondarenko
1 parent 1236e89b

Ota package controller description

@@ -177,6 +177,7 @@ public abstract class BaseController { @@ -177,6 +177,7 @@ public abstract class BaseController {
177 public static final String ASSET_ID_PARAM_DESCRIPTION = "A string value representing the asset id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 177 public static final String ASSET_ID_PARAM_DESCRIPTION = "A string value representing the asset id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
178 public static final String ALARM_ID_PARAM_DESCRIPTION = "A string value representing the alarm id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 178 public static final String ALARM_ID_PARAM_DESCRIPTION = "A string value representing the alarm id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
179 public static final String ENTITY_ID_PARAM_DESCRIPTION = "A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 179 public static final String ENTITY_ID_PARAM_DESCRIPTION = "A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
  180 + public static final String OTA_PACKAGE_ID_PARAM_DESCRIPTION = "A string value representing the ota package id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
180 public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'"; 181 public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'";
181 public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 182 public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
182 public static final String WIDGET_BUNDLE_ID_PARAM_DESCRIPTION = "A string value representing the widget bundle id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 183 public static final String WIDGET_BUNDLE_ID_PARAM_DESCRIPTION = "A string value representing the widget bundle id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
@@ -242,6 +243,11 @@ public abstract class BaseController { @@ -242,6 +243,11 @@ public abstract class BaseController {
242 protected static final String DEVICE_PROFILE_INFO_DESCRIPTION = "Device Profile Info is a lightweight object that includes main information about Device Profile excluding the heavyweight configuration object. "; 243 protected static final String DEVICE_PROFILE_INFO_DESCRIPTION = "Device Profile Info is a lightweight object that includes main information about Device Profile excluding the heavyweight configuration object. ";
243 protected static final String QUEUE_SERVICE_TYPE_DESCRIPTION = "Service type (implemented only for the TB-RULE-ENGINE)"; 244 protected static final String QUEUE_SERVICE_TYPE_DESCRIPTION = "Service type (implemented only for the TB-RULE-ENGINE)";
244 protected static final String QUEUE_SERVICE_TYPE_ALLOWABLE_VALUES = "TB-RULE-ENGINE, TB-CORE, TB-TRANSPORT, JS-EXECUTOR"; 245 protected static final String QUEUE_SERVICE_TYPE_ALLOWABLE_VALUES = "TB-RULE-ENGINE, TB-CORE, TB-TRANSPORT, JS-EXECUTOR";
  246 + protected static final String OTA_PACKAGE_INFO_DESCRIPTION = "OTA Package Info is a lightweight object that includes main information about the OTA Package excluding the heavyweight data. ";
  247 + protected static final String OTA_PACKAGE_DESCRIPTION = "OTA Package is a heavyweight object that includes main information about the OTA Package and also data. ";
  248 + protected static final String OTA_PACKAGE_CHECKSUM_ALGORITHM_ALLOWABLE_VALUES = "MD5, SHA256, SHA384, SHA512, CRC32, MURMUR3_32, MURMUR3_128";
  249 + protected static final String OTA_PACKAGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the ota package title.";
  250 + protected static final String OTA_PACKAGE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, type, title, version, tag, url, fileName, dataSize, checksum";
245 251
246 protected static final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name."; 252 protected static final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name.";
247 protected static final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name."; 253 protected static final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name.";
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 */ 15 */
16 package org.thingsboard.server.controller; 16 package org.thingsboard.server.controller;
17 17
  18 +import io.swagger.annotations.ApiOperation;
  19 +import io.swagger.annotations.ApiParam;
18 import lombok.extern.slf4j.Slf4j; 20 import lombok.extern.slf4j.Slf4j;
19 import org.apache.commons.lang3.StringUtils; 21 import org.apache.commons.lang3.StringUtils;
20 import org.springframework.core.io.ByteArrayResource; 22 import org.springframework.core.io.ByteArrayResource;
@@ -56,10 +58,12 @@ public class OtaPackageController extends BaseController { @@ -56,10 +58,12 @@ public class OtaPackageController extends BaseController {
56 public static final String OTA_PACKAGE_ID = "otaPackageId"; 58 public static final String OTA_PACKAGE_ID = "otaPackageId";
57 public static final String CHECKSUM_ALGORITHM = "checksumAlgorithm"; 59 public static final String CHECKSUM_ALGORITHM = "checksumAlgorithm";
58 60
  61 + @ApiOperation(value = "Download OTA Package (downloadOtaPackage)", notes = "Download OTA Package based on the provided OTA Package Id." + TENANT_AUTHORITY_PARAGRAPH)
59 @PreAuthorize("hasAnyAuthority( 'TENANT_ADMIN')") 62 @PreAuthorize("hasAnyAuthority( 'TENANT_ADMIN')")
60 @RequestMapping(value = "/otaPackage/{otaPackageId}/download", method = RequestMethod.GET) 63 @RequestMapping(value = "/otaPackage/{otaPackageId}/download", method = RequestMethod.GET)
61 @ResponseBody 64 @ResponseBody
62 - public ResponseEntity<org.springframework.core.io.Resource> downloadOtaPackage(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { 65 + public ResponseEntity<org.springframework.core.io.Resource> downloadOtaPackage(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION)
  66 + @PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException {
63 checkParameter(OTA_PACKAGE_ID, strOtaPackageId); 67 checkParameter(OTA_PACKAGE_ID, strOtaPackageId);
64 try { 68 try {
65 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); 69 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId));
@@ -81,10 +85,15 @@ public class OtaPackageController extends BaseController { @@ -81,10 +85,15 @@ public class OtaPackageController extends BaseController {
81 } 85 }
82 } 86 }
83 87
  88 + @ApiOperation(value = "Get OTA Package Info (getOtaPackageInfoById)",
  89 + notes = "Fetch the OTA Package Info object based on the provided OTA Package Id. " +
  90 + OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
  91 + produces = "application/json")
84 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 92 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
85 @RequestMapping(value = "/otaPackage/info/{otaPackageId}", method = RequestMethod.GET) 93 @RequestMapping(value = "/otaPackage/info/{otaPackageId}", method = RequestMethod.GET)
86 @ResponseBody 94 @ResponseBody
87 - public OtaPackageInfo getOtaPackageInfoById(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { 95 + public OtaPackageInfo getOtaPackageInfoById(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION)
  96 + @PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException {
88 checkParameter(OTA_PACKAGE_ID, strOtaPackageId); 97 checkParameter(OTA_PACKAGE_ID, strOtaPackageId);
89 try { 98 try {
90 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); 99 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId));
@@ -94,10 +103,15 @@ public class OtaPackageController extends BaseController { @@ -94,10 +103,15 @@ public class OtaPackageController extends BaseController {
94 } 103 }
95 } 104 }
96 105
  106 + @ApiOperation(value = "Get OTA Package (getOtaPackageById)",
  107 + notes = "Fetch the OTA Package object based on the provided OTA Package Id. " +
  108 + "The server checks that the OTA Package is owned by the same tenant. " + OTA_PACKAGE_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH,
  109 + produces = "application/json")
97 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 110 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
98 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.GET) 111 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.GET)
99 @ResponseBody 112 @ResponseBody
100 - public OtaPackage getOtaPackageById(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { 113 + public OtaPackage getOtaPackageById(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION)
  114 + @PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException {
101 checkParameter(OTA_PACKAGE_ID, strOtaPackageId); 115 checkParameter(OTA_PACKAGE_ID, strOtaPackageId);
102 try { 116 try {
103 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); 117 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId));
@@ -107,10 +121,19 @@ public class OtaPackageController extends BaseController { @@ -107,10 +121,19 @@ public class OtaPackageController extends BaseController {
107 } 121 }
108 } 122 }
109 123
  124 + @ApiOperation(value = "Create Or Update OTA Package Info (saveOtaPackageInfo)",
  125 + notes = "Create or update the OTA Package Info. When creating OTA Package Info, platform generates OTA Package id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
  126 + "The newly created OTA Package id will be present in the response. " +
  127 + "Specify existing OTA Package id to update the OTA Package Info. " +
  128 + "Referencing non-existing OTA Package Id will cause 'Not Found' error. " +
  129 + "\n\nOTA Package combination of the title with the version is unique in the scope of tenant. " + TENANT_AUTHORITY_PARAGRAPH,
  130 + produces = "application/json",
  131 + consumes = "application/json")
110 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 132 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
111 @RequestMapping(value = "/otaPackage", method = RequestMethod.POST) 133 @RequestMapping(value = "/otaPackage", method = RequestMethod.POST)
112 @ResponseBody 134 @ResponseBody
113 - public OtaPackageInfo saveOtaPackageInfo(@RequestBody SaveOtaPackageInfoRequest otaPackageInfo) throws ThingsboardException { 135 + public OtaPackageInfo saveOtaPackageInfo(@ApiParam(value = "A JSON value representing the OTA Package.")
  136 + @RequestBody SaveOtaPackageInfoRequest otaPackageInfo) throws ThingsboardException {
114 boolean created = otaPackageInfo.getId() == null; 137 boolean created = otaPackageInfo.getId() == null;
115 try { 138 try {
116 otaPackageInfo.setTenantId(getTenantId()); 139 otaPackageInfo.setTenantId(getTenantId());
@@ -126,13 +149,20 @@ public class OtaPackageController extends BaseController { @@ -126,13 +149,20 @@ public class OtaPackageController extends BaseController {
126 } 149 }
127 } 150 }
128 151
  152 + @ApiOperation(value = "Save OTA Package data (saveOtaPackageData)",
  153 + notes = "Update the OTA Package. Adds the date to the existing OTA Package Info" + TENANT_AUTHORITY_PARAGRAPH,
  154 + produces = "application/json")
129 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 155 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
130 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.POST) 156 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.POST)
131 @ResponseBody 157 @ResponseBody
132 - public OtaPackageInfo saveOtaPackageData(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId,  
133 - @RequestParam(required = false) String checksum,  
134 - @RequestParam(CHECKSUM_ALGORITHM) String checksumAlgorithmStr,  
135 - @RequestBody MultipartFile file) throws ThingsboardException { 158 + public OtaPackageInfo saveOtaPackageData(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION)
  159 + @PathVariable(OTA_PACKAGE_ID) String strOtaPackageId,
  160 + @ApiParam(value = "OTA Package checksum. For example, '0xd87f7e0c'")
  161 + @RequestParam(required = false) String checksum,
  162 + @ApiParam(value = "OTA Package checksum algorithm.", allowableValues = OTA_PACKAGE_CHECKSUM_ALGORITHM_ALLOWABLE_VALUES)
  163 + @RequestParam(CHECKSUM_ALGORITHM) String checksumAlgorithmStr,
  164 + @ApiParam(value = "OTA Package data.")
  165 + @RequestBody MultipartFile file) throws ThingsboardException {
136 checkParameter(OTA_PACKAGE_ID, strOtaPackageId); 166 checkParameter(OTA_PACKAGE_ID, strOtaPackageId);
137 checkParameter(CHECKSUM_ALGORITHM, checksumAlgorithmStr); 167 checkParameter(CHECKSUM_ALGORITHM, checksumAlgorithmStr);
138 try { 168 try {
@@ -171,14 +201,23 @@ public class OtaPackageController extends BaseController { @@ -171,14 +201,23 @@ public class OtaPackageController extends BaseController {
171 } 201 }
172 } 202 }
173 203
  204 + @ApiOperation(value = "Get OTA Package Infos (getOtaPackages)",
  205 + notes = "Returns a page of OTA Package Info objects owned by tenant. " +
  206 + PAGE_DATA_PARAMETERS + OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
  207 + produces = "application/json")
174 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 208 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
175 @RequestMapping(value = "/otaPackages", method = RequestMethod.GET) 209 @RequestMapping(value = "/otaPackages", method = RequestMethod.GET)
176 @ResponseBody 210 @ResponseBody
177 - public PageData<OtaPackageInfo> getOtaPackages(@RequestParam int pageSize,  
178 - @RequestParam int page,  
179 - @RequestParam(required = false) String textSearch,  
180 - @RequestParam(required = false) String sortProperty,  
181 - @RequestParam(required = false) String sortOrder) throws ThingsboardException { 211 + public PageData<OtaPackageInfo> getOtaPackages(@ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
  212 + @RequestParam int pageSize,
  213 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
  214 + @RequestParam int page,
  215 + @ApiParam(value = OTA_PACKAGE_TEXT_SEARCH_DESCRIPTION)
  216 + @RequestParam(required = false) String textSearch,
  217 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = OTA_PACKAGE_SORT_PROPERTY_ALLOWABLE_VALUES)
  218 + @RequestParam(required = false) String sortProperty,
  219 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
  220 + @RequestParam(required = false) String sortOrder) throws ThingsboardException {
182 try { 221 try {
183 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); 222 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
184 return checkNotNull(otaPackageService.findTenantOtaPackagesByTenantId(getTenantId(), pageLink)); 223 return checkNotNull(otaPackageService.findTenantOtaPackagesByTenantId(getTenantId(), pageLink));
@@ -187,15 +226,26 @@ public class OtaPackageController extends BaseController { @@ -187,15 +226,26 @@ public class OtaPackageController extends BaseController {
187 } 226 }
188 } 227 }
189 228
  229 + @ApiOperation(value = "Get OTA Package Infos (getOtaPackages)",
  230 + notes = "Returns a page of OTA Package Info objects owned by tenant. " +
  231 + PAGE_DATA_PARAMETERS + OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
  232 + produces = "application/json")
190 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 233 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
191 @RequestMapping(value = "/otaPackages/{deviceProfileId}/{type}", method = RequestMethod.GET) 234 @RequestMapping(value = "/otaPackages/{deviceProfileId}/{type}", method = RequestMethod.GET)
192 @ResponseBody 235 @ResponseBody
193 - public PageData<OtaPackageInfo> getOtaPackages(@PathVariable("deviceProfileId") String strDeviceProfileId, 236 + public PageData<OtaPackageInfo> getOtaPackages(@ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION)
  237 + @PathVariable("deviceProfileId") String strDeviceProfileId,
  238 + @ApiParam(value = "OTA Package type.", allowableValues = "FIRMWARE, SOFTWARE")
194 @PathVariable("type") String strType, 239 @PathVariable("type") String strType,
  240 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
195 @RequestParam int pageSize, 241 @RequestParam int pageSize,
  242 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
196 @RequestParam int page, 243 @RequestParam int page,
  244 + @ApiParam(value = OTA_PACKAGE_TEXT_SEARCH_DESCRIPTION)
197 @RequestParam(required = false) String textSearch, 245 @RequestParam(required = false) String textSearch,
  246 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = OTA_PACKAGE_SORT_PROPERTY_ALLOWABLE_VALUES)
198 @RequestParam(required = false) String sortProperty, 247 @RequestParam(required = false) String sortProperty,
  248 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
199 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 249 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
200 checkParameter("deviceProfileId", strDeviceProfileId); 250 checkParameter("deviceProfileId", strDeviceProfileId);
201 checkParameter("type", strType); 251 checkParameter("type", strType);
@@ -208,10 +258,15 @@ public class OtaPackageController extends BaseController { @@ -208,10 +258,15 @@ public class OtaPackageController extends BaseController {
208 } 258 }
209 } 259 }
210 260
  261 + @ApiOperation(value = "Delete OTA Package (deleteOtaPackage)",
  262 + notes = "Deletes the OTA Package. Referencing non-existing OTA Package Id will cause an error. " +
  263 + "Can't delete the OTA Package if it is referenced by existing devices or device profile." + TENANT_AUTHORITY_PARAGRAPH,
  264 + produces = "application/json")
211 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 265 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
212 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.DELETE) 266 @RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.DELETE)
213 @ResponseBody 267 @ResponseBody
214 - public void deleteOtaPackage(@PathVariable("otaPackageId") String strOtaPackageId) throws ThingsboardException { 268 + public void deleteOtaPackage(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION)
  269 + @PathVariable("otaPackageId") String strOtaPackageId) throws ThingsboardException {
215 checkParameter(OTA_PACKAGE_ID, strOtaPackageId); 270 checkParameter(OTA_PACKAGE_ID, strOtaPackageId);
216 try { 271 try {
217 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); 272 OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId));
@@ -15,18 +15,22 @@ @@ -15,18 +15,22 @@
15 */ 15 */
16 package org.thingsboard.server.common.data; 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 20 import lombok.Data;
19 import lombok.EqualsAndHashCode; 21 import lombok.EqualsAndHashCode;
20 import org.thingsboard.server.common.data.id.OtaPackageId; 22 import org.thingsboard.server.common.data.id.OtaPackageId;
21 23
22 import java.nio.ByteBuffer; 24 import java.nio.ByteBuffer;
23 25
  26 +@ApiModel
24 @Data 27 @Data
25 @EqualsAndHashCode(callSuper = true) 28 @EqualsAndHashCode(callSuper = true)
26 public class OtaPackage extends OtaPackageInfo { 29 public class OtaPackage extends OtaPackageInfo {
27 30
28 private static final long serialVersionUID = 3091601761339422546L; 31 private static final long serialVersionUID = 3091601761339422546L;
29 32
  33 + @ApiModelProperty(position = 16, value = "OTA Package data.", readOnly = true)
30 private transient ByteBuffer data; 34 private transient ByteBuffer data;
31 35
32 public OtaPackage() { 36 public OtaPackage() {
@@ -16,15 +16,19 @@ @@ -16,15 +16,19 @@
16 package org.thingsboard.server.common.data; 16 package org.thingsboard.server.common.data;
17 17
18 import com.fasterxml.jackson.annotation.JsonIgnore; 18 import com.fasterxml.jackson.annotation.JsonIgnore;
  19 +import com.fasterxml.jackson.databind.JsonNode;
  20 +import io.swagger.annotations.ApiModel;
  21 +import io.swagger.annotations.ApiModelProperty;
19 import lombok.Data; 22 import lombok.Data;
20 import lombok.EqualsAndHashCode; 23 import lombok.EqualsAndHashCode;
21 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
22 -import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;  
23 -import org.thingsboard.server.common.data.ota.OtaPackageType;  
24 import org.thingsboard.server.common.data.id.DeviceProfileId; 25 import org.thingsboard.server.common.data.id.DeviceProfileId;
25 import org.thingsboard.server.common.data.id.OtaPackageId; 26 import org.thingsboard.server.common.data.id.OtaPackageId;
26 import org.thingsboard.server.common.data.id.TenantId; 27 import org.thingsboard.server.common.data.id.TenantId;
  28 +import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
  29 +import org.thingsboard.server.common.data.ota.OtaPackageType;
27 30
  31 +@ApiModel
28 @Slf4j 32 @Slf4j
29 @Data 33 @Data
30 @EqualsAndHashCode(callSuper = true) 34 @EqualsAndHashCode(callSuper = true)
@@ -32,21 +36,33 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage @@ -32,21 +36,33 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage
32 36
33 private static final long serialVersionUID = 3168391583570815419L; 37 private static final long serialVersionUID = 3168391583570815419L;
34 38
  39 + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id. Tenant Id of the ota package can't be changed.", readOnly = true)
35 private TenantId tenantId; 40 private TenantId tenantId;
  41 + @ApiModelProperty(position = 4, value = "JSON object with Device Profile Id. Device Profile Id of the ota package can't be changed.", readOnly = true)
36 private DeviceProfileId deviceProfileId; 42 private DeviceProfileId deviceProfileId;
  43 + @ApiModelProperty(position = 5, value = "OTA Package type.", example = "FIRMWARE", readOnly = true)
37 private OtaPackageType type; 44 private OtaPackageType type;
  45 + @ApiModelProperty(position = 6, value = "OTA Package title.", example = "fw", readOnly = true)
38 private String title; 46 private String title;
  47 + @ApiModelProperty(position = 7, value = "OTA Package version.", example = "1.0", readOnly = true)
39 private String version; 48 private String version;
  49 + @ApiModelProperty(position = 8, value = "OTA Package tag.", example = "fw_1.0", readOnly = true)
40 private String tag; 50 private String tag;
  51 + @ApiModelProperty(position = 9, value = "OTA Package url.", example = "http://thingsboard.org/fw/1", readOnly = true)
41 private String url; 52 private String url;
  53 + @ApiModelProperty(position = 10, value = "Indicates OTA Package 'has data'. Field is returned from DB ('true' if data exists or url is set). If OTA Package 'has data' is 'false' we can not assign the OTA Package to the Device or Device Profile.", example = "true", readOnly = true)
42 private boolean hasData; 54 private boolean hasData;
  55 + @ApiModelProperty(position = 11, value = "OTA Package file name.", example = "fw_1.0", readOnly = true)
43 private String fileName; 56 private String fileName;
  57 + @ApiModelProperty(position = 12, value = "OTA Package content type.", example = "APPLICATION_OCTET_STREAM", readOnly = true)
44 private String contentType; 58 private String contentType;
  59 + @ApiModelProperty(position = 13, value = "OTA Package checksum algorithm.", example = "CRC32", readOnly = true)
45 private ChecksumAlgorithm checksumAlgorithm; 60 private ChecksumAlgorithm checksumAlgorithm;
  61 + @ApiModelProperty(position = 14, value = "OTA Package checksum.", example = "0xd87f7e0c", readOnly = true)
46 private String checksum; 62 private String checksum;
  63 + @ApiModelProperty(position = 15, value = "OTA Package data size.", example = "8", readOnly = true)
47 private Long dataSize; 64 private Long dataSize;
48 65
49 -  
50 public OtaPackageInfo() { 66 public OtaPackageInfo() {
51 super(); 67 super();
52 } 68 }
@@ -72,6 +88,21 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage @@ -72,6 +88,21 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage
72 this.dataSize = otaPackageInfo.getDataSize(); 88 this.dataSize = otaPackageInfo.getDataSize();
73 } 89 }
74 90
  91 + @ApiModelProperty(position = 1, value = "JSON object with the ota package Id. " +
  92 + "Specify existing ota package Id to update the ota package. " +
  93 + "Referencing non-existing ota package id will cause error. " +
  94 + "Omit this field to create new ota package.")
  95 + @Override
  96 + public OtaPackageId getId() {
  97 + return super.getId();
  98 + }
  99 +
  100 + @ApiModelProperty(position = 2, value = "Timestamp of the ota package creation, in milliseconds", example = "1609459200000", readOnly = true)
  101 + @Override
  102 + public long getCreatedTime() {
  103 + return super.getCreatedTime();
  104 + }
  105 +
75 @Override 106 @Override
76 public String getSearchText() { 107 public String getSearchText() {
77 return title; 108 return title;
@@ -87,4 +118,10 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage @@ -87,4 +118,10 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage
87 public boolean hasUrl() { 118 public boolean hasUrl() {
88 return StringUtils.isNotEmpty(url); 119 return StringUtils.isNotEmpty(url);
89 } 120 }
  121 +
  122 + @ApiModelProperty(position = 17, value = "OTA Package description.", example = "Description for the OTA Package fw_1.0")
  123 + @Override
  124 + public JsonNode getAdditionalInfo() {
  125 + return super.getAdditionalInfo();
  126 + }
90 } 127 }
@@ -15,14 +15,18 @@ @@ -15,14 +15,18 @@
15 */ 15 */
16 package org.thingsboard.server.common.data; 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 20 import lombok.Data;
19 import lombok.EqualsAndHashCode; 21 import lombok.EqualsAndHashCode;
20 import lombok.NoArgsConstructor; 22 import lombok.NoArgsConstructor;
21 23
  24 +@ApiModel
22 @Data 25 @Data
23 @EqualsAndHashCode(callSuper = true) 26 @EqualsAndHashCode(callSuper = true)
24 @NoArgsConstructor 27 @NoArgsConstructor
25 -public class SaveOtaPackageInfoRequest extends OtaPackageInfo{ 28 +public class SaveOtaPackageInfoRequest extends OtaPackageInfo {
  29 + @ApiModelProperty(position = 16, value = "Indicates OTA Package uses url. Should be 'true' if uses url or 'false' if will be used data.", example = "true", readOnly = true)
26 boolean usesUrl; 30 boolean usesUrl;
27 31
28 public SaveOtaPackageInfoRequest(OtaPackageInfo otaPackageInfo, boolean usesUrl) { 32 public SaveOtaPackageInfoRequest(OtaPackageInfo otaPackageInfo, boolean usesUrl) {