Showing
4 changed files
with
140 additions
and
23 deletions
... | ... | @@ -165,7 +165,7 @@ public abstract class BaseController { |
165 | 165 | "See the 'Model' tab of the Response Class for more details. "; |
166 | 166 | public static final String DASHBOARD_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
167 | 167 | public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
168 | - public static final String DEVICE_PROFILE_ID_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | |
168 | + public static final String DEVICE_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | |
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'"; |
... | ... | @@ -176,6 +176,8 @@ public abstract class BaseController { |
176 | 176 | public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'"; |
177 | 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'"; |
178 | 178 | |
179 | + protected static final String TENANT_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' authority."; | |
180 | + protected static final String TENANT_AND_USER_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority."; | |
179 | 181 | |
180 | 182 | protected static final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page"; |
181 | 183 | protected static final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0"; |
... | ... | @@ -186,6 +188,7 @@ public abstract class BaseController { |
186 | 188 | protected static final String ASSET_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the asset name."; |
187 | 189 | protected static final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title."; |
188 | 190 | protected static final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name."; |
191 | + protected static final String DEVICE_PROFILE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device profile name."; | |
189 | 192 | protected static final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title."; |
190 | 193 | protected static final String EDGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge name."; |
191 | 194 | protected static final String EVENT_TEXT_SEARCH_DESCRIPTION = "The value is not used in searching."; |
... | ... | @@ -194,6 +197,7 @@ public abstract class BaseController { |
194 | 197 | protected static final String DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title"; |
195 | 198 | protected static final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city"; |
196 | 199 | protected static final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle"; |
200 | + protected static final String DEVICE_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, transportType, description, isDefault"; | |
197 | 201 | protected static final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle"; |
198 | 202 | protected static final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status"; |
199 | 203 | protected static final String EVENT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, id"; |
... | ... | @@ -201,11 +205,13 @@ public abstract class BaseController { |
201 | 205 | protected static final String AUDIT_LOG_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, entityType, entityName, userName, actionType, actionStatus"; |
202 | 206 | protected static final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESC (DESCENDING)"; |
203 | 207 | protected static final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC"; |
208 | + protected static final String TRANSPORT_TYPE_ALLOWABLE_VALUES = "DEFAULT, MQTT, COAP, LWM2M, SNMP"; | |
204 | 209 | 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 | 210 | 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 | 211 | 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 | 212 | 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 | 213 | 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. "; |
214 | + 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. "; | |
209 | 215 | |
210 | 216 | protected static final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name."; |
211 | 217 | protected static final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name."; | ... | ... |
... | ... | @@ -415,7 +415,7 @@ public class DeviceController extends BaseController { |
415 | 415 | @RequestParam int page, |
416 | 416 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
417 | 417 | @RequestParam(required = false) String type, |
418 | - @ApiParam(value = DEVICE_PROFILE_ID_DESCRIPTION) | |
418 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
419 | 419 | @RequestParam(required = false) String deviceProfileId, |
420 | 420 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
421 | 421 | @RequestParam(required = false) String textSearch, |
... | ... | @@ -509,7 +509,7 @@ public class DeviceController extends BaseController { |
509 | 509 | @RequestParam int page, |
510 | 510 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
511 | 511 | @RequestParam(required = false) String type, |
512 | - @ApiParam(value = DEVICE_PROFILE_ID_DESCRIPTION) | |
512 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
513 | 513 | @RequestParam(required = false) String deviceProfileId, |
514 | 514 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
515 | 515 | @RequestParam(required = false) String textSearch, | ... | ... |
... | ... | @@ -15,6 +15,8 @@ |
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 lombok.extern.slf4j.Slf4j; |
19 | 21 | import org.apache.commons.lang3.StringUtils; |
20 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -58,10 +60,16 @@ public class DeviceProfileController extends BaseController { |
58 | 60 | @Autowired |
59 | 61 | private TimeseriesService timeseriesService; |
60 | 62 | |
63 | + @ApiOperation(value = "Get Device Profile (getDeviceProfileById)", | |
64 | + notes = "Fetch the Device Profile object based on the provided Device Profile Id. " + | |
65 | + "The server checks that the device profile is owned by the same tenant. " + TENANT_AUTHORITY_PARAGRAPH, | |
66 | + produces = "application/json") | |
61 | 67 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
62 | 68 | @RequestMapping(value = "/deviceProfile/{deviceProfileId}", method = RequestMethod.GET) |
63 | 69 | @ResponseBody |
64 | - public DeviceProfile getDeviceProfileById(@PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
70 | + public DeviceProfile getDeviceProfileById( | |
71 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
72 | + @PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
65 | 73 | checkParameter(DEVICE_PROFILE_ID, strDeviceProfileId); |
66 | 74 | try { |
67 | 75 | DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
... | ... | @@ -71,10 +79,16 @@ public class DeviceProfileController extends BaseController { |
71 | 79 | } |
72 | 80 | } |
73 | 81 | |
82 | + @ApiOperation(value = "Get Device Profile Info (getDeviceProfileInfoById)", | |
83 | + notes = "Fetch the Device Profile Info object based on the provided Device Profile Id. " | |
84 | + + DEVICE_PROFILE_INFO_DESCRIPTION + TENANT_AND_USER_AUTHORITY_PARAGRAPH, | |
85 | + produces = "application/json") | |
74 | 86 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
75 | 87 | @RequestMapping(value = "/deviceProfileInfo/{deviceProfileId}", method = RequestMethod.GET) |
76 | 88 | @ResponseBody |
77 | - public DeviceProfileInfo getDeviceProfileInfoById(@PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
89 | + public DeviceProfileInfo getDeviceProfileInfoById( | |
90 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
91 | + @PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
78 | 92 | checkParameter(DEVICE_PROFILE_ID, strDeviceProfileId); |
79 | 93 | try { |
80 | 94 | DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
... | ... | @@ -84,6 +98,10 @@ public class DeviceProfileController extends BaseController { |
84 | 98 | } |
85 | 99 | } |
86 | 100 | |
101 | + @ApiOperation(value = "Get Default Device Profile (getDefaultDeviceProfileInfo)", | |
102 | + notes = "Fetch the Default Device Profile Info object. " + | |
103 | + DEVICE_PROFILE_INFO_DESCRIPTION + TENANT_AND_USER_AUTHORITY_PARAGRAPH, | |
104 | + produces = "application/json") | |
87 | 105 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
88 | 106 | @RequestMapping(value = "/deviceProfileInfo/default", method = RequestMethod.GET) |
89 | 107 | @ResponseBody |
... | ... | @@ -95,10 +113,18 @@ public class DeviceProfileController extends BaseController { |
95 | 113 | } |
96 | 114 | } |
97 | 115 | |
116 | + @ApiOperation(value = "Get time-series keys (getTimeseriesKeys)", | |
117 | + notes = "Get a set of unique time-series keys used by devices that belong to specified profile. " + | |
118 | + "If profile is not set returns a list of unique keys among all profiles. " + | |
119 | + "The call is used for auto-complete in the UI forms. " + | |
120 | + "The implementation limits the number of devices that participate in search to 100 as a trade of between accurate results and time-consuming queries. " + | |
121 | + TENANT_AUTHORITY_PARAGRAPH, | |
122 | + produces = "application/json") | |
98 | 123 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
99 | 124 | @RequestMapping(value = "/deviceProfile/devices/keys/timeseries", method = RequestMethod.GET) |
100 | 125 | @ResponseBody |
101 | 126 | public List<String> getTimeseriesKeys( |
127 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
102 | 128 | @RequestParam(name = DEVICE_PROFILE_ID, required = false) String deviceProfileIdStr) throws ThingsboardException { |
103 | 129 | DeviceProfileId deviceProfileId; |
104 | 130 | if (StringUtils.isNotEmpty(deviceProfileIdStr)) { |
... | ... | @@ -115,10 +141,18 @@ public class DeviceProfileController extends BaseController { |
115 | 141 | } |
116 | 142 | } |
117 | 143 | |
144 | + @ApiOperation(value = "Get attribute keys (getAttributesKeys)", | |
145 | + notes = "Get a set of unique attribute keys used by devices that belong to specified profile. " + | |
146 | + "If profile is not set returns a list of unique keys among all profiles. " + | |
147 | + "The call is used for auto-complete in the UI forms. " + | |
148 | + "The implementation limits the number of devices that participate in search to 100 as a trade of between accurate results and time-consuming queries. " + | |
149 | + TENANT_AUTHORITY_PARAGRAPH, | |
150 | + produces = "application/json") | |
118 | 151 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
119 | 152 | @RequestMapping(value = "/deviceProfile/devices/keys/attributes", method = RequestMethod.GET) |
120 | 153 | @ResponseBody |
121 | 154 | public List<String> getAttributesKeys( |
155 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
122 | 156 | @RequestParam(name = DEVICE_PROFILE_ID, required = false) String deviceProfileIdStr) throws ThingsboardException { |
123 | 157 | DeviceProfileId deviceProfileId; |
124 | 158 | if (StringUtils.isNotEmpty(deviceProfileIdStr)) { |
... | ... | @@ -135,10 +169,20 @@ public class DeviceProfileController extends BaseController { |
135 | 169 | } |
136 | 170 | } |
137 | 171 | |
172 | + @ApiOperation(value = "Create Or Update Device Profile (saveDevice)", | |
173 | + notes = "Create or update the Device Profile. When creating device profile, platform generates device profile id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " + | |
174 | + "The newly created device profile id will be present in the response. " + | |
175 | + "Specify existing device profile id to update the device profile. " + | |
176 | + "Referencing non-existing device profile Id will cause 'Not Found' error. " + | |
177 | + "\n\nDevice profile name is unique in the scope of tenant. Only one 'default' device profile may exist in scope of tenant." + TENANT_AUTHORITY_PARAGRAPH, | |
178 | + produces = "application/json", | |
179 | + consumes = "application/json") | |
138 | 180 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
139 | 181 | @RequestMapping(value = "/deviceProfile", method = RequestMethod.POST) |
140 | 182 | @ResponseBody |
141 | - public DeviceProfile saveDeviceProfile(@RequestBody DeviceProfile deviceProfile) throws ThingsboardException { | |
183 | + public DeviceProfile saveDeviceProfile( | |
184 | + @ApiParam(value = "A JSON value representing the device profile.") | |
185 | + @RequestBody DeviceProfile deviceProfile) throws ThingsboardException { | |
142 | 186 | try { |
143 | 187 | boolean created = deviceProfile.getId() == null; |
144 | 188 | deviceProfile.setTenantId(getTenantId()); |
... | ... | @@ -180,10 +224,16 @@ public class DeviceProfileController extends BaseController { |
180 | 224 | } |
181 | 225 | } |
182 | 226 | |
227 | + @ApiOperation(value = "Delete device profile (deleteDeviceProfile)", | |
228 | + notes = "Deletes the device profile. Referencing non-existing device profile Id will cause an error. " + | |
229 | + "Can't delete the device profile if it is referenced by existing devices." + TENANT_AUTHORITY_PARAGRAPH, | |
230 | + produces = "application/json") | |
183 | 231 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
184 | 232 | @RequestMapping(value = "/deviceProfile/{deviceProfileId}", method = RequestMethod.DELETE) |
185 | 233 | @ResponseStatus(value = HttpStatus.OK) |
186 | - public void deleteDeviceProfile(@PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
234 | + public void deleteDeviceProfile( | |
235 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
236 | + @PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
187 | 237 | checkParameter(DEVICE_PROFILE_ID, strDeviceProfileId); |
188 | 238 | try { |
189 | 239 | DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
... | ... | @@ -207,10 +257,15 @@ public class DeviceProfileController extends BaseController { |
207 | 257 | } |
208 | 258 | } |
209 | 259 | |
260 | + @ApiOperation(value = "Make Device Profile Default (setDefaultDeviceProfile)", | |
261 | + notes = "Marks device profile as default within a tenant scope." + TENANT_AUTHORITY_PARAGRAPH, | |
262 | + produces = "application/json") | |
210 | 263 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
211 | 264 | @RequestMapping(value = "/deviceProfile/{deviceProfileId}/default", method = RequestMethod.POST) |
212 | 265 | @ResponseBody |
213 | - public DeviceProfile setDefaultDeviceProfile(@PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
266 | + public DeviceProfile setDefaultDeviceProfile( | |
267 | + @ApiParam(value = DEVICE_PROFILE_ID_PARAM_DESCRIPTION) | |
268 | + @PathVariable(DEVICE_PROFILE_ID) String strDeviceProfileId) throws ThingsboardException { | |
214 | 269 | checkParameter(DEVICE_PROFILE_ID, strDeviceProfileId); |
215 | 270 | try { |
216 | 271 | DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
... | ... | @@ -238,14 +293,24 @@ public class DeviceProfileController extends BaseController { |
238 | 293 | } |
239 | 294 | } |
240 | 295 | |
296 | + @ApiOperation(value = "Get Device Profiles (getDeviceProfiles)", | |
297 | + notes = "Returns a page of devices profile objects owned by tenant. " + | |
298 | + PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH, | |
299 | + produces = "application/json") | |
241 | 300 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
242 | 301 | @RequestMapping(value = "/deviceProfiles", params = {"pageSize", "page"}, method = RequestMethod.GET) |
243 | 302 | @ResponseBody |
244 | - public PageData<DeviceProfile> getDeviceProfiles(@RequestParam int pageSize, | |
245 | - @RequestParam int page, | |
246 | - @RequestParam(required = false) String textSearch, | |
247 | - @RequestParam(required = false) String sortProperty, | |
248 | - @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
303 | + public PageData<DeviceProfile> getDeviceProfiles( | |
304 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) | |
305 | + @RequestParam int pageSize, | |
306 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | |
307 | + @RequestParam int page, | |
308 | + @ApiParam(value = DEVICE_PROFILE_TEXT_SEARCH_DESCRIPTION) | |
309 | + @RequestParam(required = false) String textSearch, | |
310 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES) | |
311 | + @RequestParam(required = false) String sortProperty, | |
312 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
313 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
249 | 314 | try { |
250 | 315 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
251 | 316 | return checkNotNull(deviceProfileService.findDeviceProfiles(getTenantId(), pageLink)); |
... | ... | @@ -254,15 +319,26 @@ public class DeviceProfileController extends BaseController { |
254 | 319 | } |
255 | 320 | } |
256 | 321 | |
322 | + @ApiOperation(value = "Get Device Profiles for transport type (getDeviceProfileInfos)", | |
323 | + notes = "Returns a page of devices profile info objects owned by tenant. " + | |
324 | + PAGE_DATA_PARAMETERS + DEVICE_PROFILE_INFO_DESCRIPTION + TENANT_AND_USER_AUTHORITY_PARAGRAPH, | |
325 | + produces = "application/json") | |
257 | 326 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
258 | 327 | @RequestMapping(value = "/deviceProfileInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
259 | 328 | @ResponseBody |
260 | - public PageData<DeviceProfileInfo> getDeviceProfileInfos(@RequestParam int pageSize, | |
261 | - @RequestParam int page, | |
262 | - @RequestParam(required = false) String textSearch, | |
263 | - @RequestParam(required = false) String sortProperty, | |
264 | - @RequestParam(required = false) String sortOrder, | |
265 | - @RequestParam(required = false) String transportType) throws ThingsboardException { | |
329 | + public PageData<DeviceProfileInfo> getDeviceProfileInfos( | |
330 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) | |
331 | + @RequestParam int pageSize, | |
332 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | |
333 | + @RequestParam int page, | |
334 | + @ApiParam(value = DEVICE_PROFILE_TEXT_SEARCH_DESCRIPTION) | |
335 | + @RequestParam(required = false) String textSearch, | |
336 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES) | |
337 | + @RequestParam(required = false) String sortProperty, | |
338 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
339 | + @RequestParam(required = false) String sortOrder, | |
340 | + @ApiParam(value = "Type of the transport", allowableValues = TRANSPORT_TYPE_ALLOWABLE_VALUES) | |
341 | + @RequestParam(required = false) String transportType) throws ThingsboardException { | |
266 | 342 | try { |
267 | 343 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
268 | 344 | return checkNotNull(deviceProfileService.findDeviceProfileInfos(getTenantId(), pageLink, transportType)); | ... | ... |
... | ... | @@ -17,6 +17,8 @@ package org.thingsboard.server.common.data; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonIgnore; |
19 | 19 | import com.fasterxml.jackson.core.JsonProcessingException; |
20 | +import io.swagger.annotations.ApiModel; | |
21 | +import io.swagger.annotations.ApiModelProperty; | |
20 | 22 | import lombok.Data; |
21 | 23 | import lombok.EqualsAndHashCode; |
22 | 24 | import lombok.extern.slf4j.Slf4j; |
... | ... | @@ -34,34 +36,51 @@ import java.io.IOException; |
34 | 36 | |
35 | 37 | import static org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo.mapper; |
36 | 38 | |
39 | +@ApiModel | |
37 | 40 | @Data |
38 | 41 | @EqualsAndHashCode(callSuper = true) |
39 | 42 | @Slf4j |
40 | 43 | public class DeviceProfile extends SearchTextBased<DeviceProfileId> implements HasName, HasTenantId, HasOtaPackage { |
41 | 44 | |
45 | + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id that owns the profile.", readOnly = true) | |
42 | 46 | private TenantId tenantId; |
43 | 47 | @NoXss |
48 | + @ApiModelProperty(position = 4, value = "Unique Device Profile Name in scope of Tenant.", example = "Moisture Sensor") | |
44 | 49 | private String name; |
45 | 50 | @NoXss |
51 | + @ApiModelProperty(position = 11, value = "Device Profile description. ") | |
46 | 52 | private String description; |
53 | + @ApiModelProperty(position = 12, value = "Either URL or Base64 data of the icon. Used in the mobile application to visualize set of device profiles in the grid view. ") | |
47 | 54 | private String image; |
48 | 55 | private boolean isDefault; |
56 | + @ApiModelProperty(position = 16, value = "Type of the profile. Always 'DEFAULT' for now. Reserved for future use.") | |
49 | 57 | private DeviceProfileType type; |
58 | + @ApiModelProperty(position = 14, value = "Type of the transport used to connect the device. Default transport supports HTTP, CoAP and MQTT.") | |
50 | 59 | private DeviceTransportType transportType; |
60 | + @ApiModelProperty(position = 15, value = "Provisioning strategy.") | |
51 | 61 | private DeviceProfileProvisionType provisionType; |
62 | + @ApiModelProperty(position = 7, value = "Reference to the rule chain. " + | |
63 | + "If present, the specified rule chain will be used to process all messages related to device, including telemetry, attribute updates, etc. " + | |
64 | + "Otherwise, the root rule chain will be used to process those messages.") | |
52 | 65 | private RuleChainId defaultRuleChainId; |
66 | + @ApiModelProperty(position = 6, value = "Reference to the dashboard. Used in the mobile application to open the default dashboard when user navigates to device details.") | |
53 | 67 | private DashboardId defaultDashboardId; |
54 | 68 | @NoXss |
69 | + @ApiModelProperty(position = 8, value = "Reference to the rule engine queue. " + | |
70 | + "If present, the specified queue will be used to store all unprocessed messages related to device, including telemetry, attribute updates, etc. " + | |
71 | + "Otherwise, the 'Main' queue will be used to store those messages.") | |
55 | 72 | private String defaultQueueName; |
56 | 73 | @Valid |
57 | 74 | private transient DeviceProfileData profileData; |
58 | 75 | @JsonIgnore |
59 | 76 | private byte[] profileDataBytes; |
60 | 77 | @NoXss |
78 | + @ApiModelProperty(position = 13, value = "Unique provisioning key used by 'Device Provisioning' feature.") | |
61 | 79 | private String provisionDeviceKey; |
62 | 80 | |
81 | + @ApiModelProperty(position = 9, value = "Reference to the firmware OTA package. If present, the specified package will be used as default device firmware. ") | |
63 | 82 | private OtaPackageId firmwareId; |
64 | - | |
83 | + @ApiModelProperty(position = 10, value = "Reference to the software OTA package. If present, the specified package will be used as default device software. ") | |
65 | 84 | private OtaPackageId softwareId; |
66 | 85 | |
67 | 86 | public DeviceProfile() { |
... | ... | @@ -88,16 +107,32 @@ public class DeviceProfile extends SearchTextBased<DeviceProfileId> implements H |
88 | 107 | this.softwareId = deviceProfile.getSoftwareId(); |
89 | 108 | } |
90 | 109 | |
110 | + @ApiModelProperty(position = 1, value = "JSON object with the device profile Id. " + | |
111 | + "Specify this field to update the device profile. " + | |
112 | + "Referencing non-existing device profile Id will cause error. " + | |
113 | + "Omit this field to create new device profile.") | |
114 | + @Override | |
115 | + public DeviceProfileId getId() { | |
116 | + return super.getId(); | |
117 | + } | |
118 | + | |
119 | + @ApiModelProperty(position = 2, value = "Timestamp of the profile creation, in milliseconds", example = "1609459200000", readOnly = true) | |
120 | + @Override | |
121 | + public long getCreatedTime() { | |
122 | + return super.getCreatedTime(); | |
123 | + } | |
124 | + | |
91 | 125 | @Override |
92 | 126 | public String getSearchText() { |
93 | 127 | return getName(); |
94 | 128 | } |
95 | 129 | |
96 | - @Override | |
97 | - public String getName() { | |
98 | - return name; | |
130 | + @ApiModelProperty(position = 5, value = "Used to mark the default profile. Default profile is used when the device profile is not specified during device creation.") | |
131 | + public boolean isDefault(){ | |
132 | + return isDefault; | |
99 | 133 | } |
100 | 134 | |
135 | + @ApiModelProperty(position = 16, value = "Complex JSON object that includes addition device profile configuration (transport, alarm rules, etc).") | |
101 | 136 | public DeviceProfileData getProfileData() { |
102 | 137 | if (profileData != null) { |
103 | 138 | return profileData; | ... | ... |