Commit 45d49153e253d10ec1cc63d4467fed8632c43d1f

Authored by Andrii Shvaika
1 parent 4ae4c7c3

Tenant and Tenant Profile Controllers

@@ -169,6 +169,7 @@ public abstract class BaseController { @@ -169,6 +169,7 @@ public abstract class BaseController {
169 public static final String RPC_ID_PARAM_DESCRIPTION = "A string value representing the rpc id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 169 public static final String RPC_ID_PARAM_DESCRIPTION = "A string value representing the rpc id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
170 public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 170 public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
171 public static final String DEVICE_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 171 public static final String DEVICE_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
  172 + public static final String TENANT_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the tenant profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
172 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 173 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
173 public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 174 public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
174 public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 175 public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
@@ -179,6 +180,8 @@ public abstract class BaseController { @@ -179,6 +180,8 @@ public abstract class BaseController {
179 public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'"; 180 public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'";
180 public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 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'";
181 182
  183 + protected static final String SYSTEM_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'SYS_ADMIN' authority.";
  184 + protected static final String SYSTEM_AND_TENANT_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.";
182 protected static final String TENANT_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' authority."; 185 protected static final String TENANT_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' authority.";
183 protected static final String TENANT_AND_USER_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority."; 186 protected static final String TENANT_AND_USER_AUTHORITY_PARAGRAPH = "\n\nAvailable for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority.";
184 187
@@ -193,6 +196,8 @@ public abstract class BaseController { @@ -193,6 +196,8 @@ public abstract class BaseController {
193 protected static final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title."; 196 protected static final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title.";
194 protected static final String RPC_TEXT_SEARCH_DESCRIPTION = "Not implemented. Leave empty."; 197 protected static final String RPC_TEXT_SEARCH_DESCRIPTION = "Not implemented. Leave empty.";
195 protected static final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name."; 198 protected static final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name.";
  199 + protected static final String TENANT_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the tenant name.";
  200 + protected static final String TENANT_PROFILE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the tenant profile name.";
196 protected static final String RULE_CHAIN_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the rule chain name."; 201 protected static final String RULE_CHAIN_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the rule chain name.";
197 protected static final String DEVICE_PROFILE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device profile name."; 202 protected static final String DEVICE_PROFILE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device profile name.";
198 protected static final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title."; 203 protected static final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title.";
@@ -204,6 +209,10 @@ public abstract class BaseController { @@ -204,6 +209,10 @@ public abstract class BaseController {
204 protected static final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city"; 209 protected static final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city";
205 protected static final String RPC_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, expirationTime, request, response"; 210 protected static final String RPC_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, expirationTime, request, response";
206 protected static final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle"; 211 protected static final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle";
  212 + protected static final String TENANT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, state, city, address, address2, zip, phone, email";
  213 + protected static final String TENANT_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, description, isDefault";
  214 + protected static final String TENANT_PROFILE_INFO_SORT_PROPERTY_ALLOWABLE_VALUES = "id, name";
  215 + protected static final String TENANT_INFO_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, tenantProfileName, title, email, country, state, city, address, address2, zip, phone, email";
207 protected static final String DEVICE_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, transportType, description, isDefault"; 216 protected static final String DEVICE_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, transportType, description, isDefault";
208 protected static final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle"; 217 protected static final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
209 protected static final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status"; 218 protected static final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status";
@@ -373,7 +373,7 @@ public class DeviceController extends BaseController { @@ -373,7 +373,7 @@ public class DeviceController extends BaseController {
373 373
374 @ApiOperation(value = "Get Tenant Devices (getTenantDevices)", 374 @ApiOperation(value = "Get Tenant Devices (getTenantDevices)",
375 notes = "Returns a page of devices owned by tenant. " + 375 notes = "Returns a page of devices owned by tenant. " +
376 - PAGE_DATA_PARAMETERS) 376 + PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
377 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 377 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
378 @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) 378 @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
379 @ResponseBody 379 @ResponseBody
@@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
16 package org.thingsboard.server.controller; 16 package org.thingsboard.server.controller;
17 17
18 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
  19 +import io.swagger.annotations.ApiOperation;
  20 +import io.swagger.annotations.ApiParam;
19 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
20 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.http.HttpStatus; 23 import org.springframework.http.HttpStatus;
@@ -47,21 +49,26 @@ import org.thingsboard.server.service.security.permission.Resource; @@ -47,21 +49,26 @@ import org.thingsboard.server.service.security.permission.Resource;
47 @Slf4j 49 @Slf4j
48 public class TenantController extends BaseController { 50 public class TenantController extends BaseController {
49 51
  52 + private static final String TENANT_INFO_DESCRIPTION = "The Tenant Info object extends regular Tenant object and includes Tenant Profile name. ";
50 @Autowired 53 @Autowired
51 private InstallScripts installScripts; 54 private InstallScripts installScripts;
52 55
53 @Autowired 56 @Autowired
54 private TenantService tenantService; 57 private TenantService tenantService;
55 58
  59 + @ApiOperation(value = "Get Tenant (getTenantById)",
  60 + notes = "Fetch the Tenant object based on the provided Tenant Id. " + SYSTEM_AND_TENANT_AUTHORITY_PARAGRAPH)
56 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") 61 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
57 @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.GET) 62 @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.GET)
58 @ResponseBody 63 @ResponseBody
59 - public Tenant getTenantById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { 64 + public Tenant getTenantById(
  65 + @ApiParam(value = TENANT_ID_PARAM_DESCRIPTION)
  66 + @PathVariable(TENANT_ID) String strTenantId) throws ThingsboardException {
60 checkParameter(TENANT_ID, strTenantId); 67 checkParameter(TENANT_ID, strTenantId);
61 try { 68 try {
62 TenantId tenantId = new TenantId(toUUID(strTenantId)); 69 TenantId tenantId = new TenantId(toUUID(strTenantId));
63 Tenant tenant = checkTenantId(tenantId, Operation.READ); 70 Tenant tenant = checkTenantId(tenantId, Operation.READ);
64 - if(!tenant.getAdditionalInfo().isNull()) { 71 + if (!tenant.getAdditionalInfo().isNull()) {
65 processDashboardIdFromAdditionalInfo((ObjectNode) tenant.getAdditionalInfo(), HOME_DASHBOARD); 72 processDashboardIdFromAdditionalInfo((ObjectNode) tenant.getAdditionalInfo(), HOME_DASHBOARD);
66 } 73 }
67 return tenant; 74 return tenant;
@@ -70,10 +77,15 @@ public class TenantController extends BaseController { @@ -70,10 +77,15 @@ public class TenantController extends BaseController {
70 } 77 }
71 } 78 }
72 79
  80 + @ApiOperation(value = "Get Tenant Info (getTenantInfoById)",
  81 + notes = "Fetch the Tenant Info object based on the provided Tenant Id. " +
  82 + TENANT_INFO_DESCRIPTION + SYSTEM_AND_TENANT_AUTHORITY_PARAGRAPH)
73 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") 83 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
74 @RequestMapping(value = "/tenant/info/{tenantId}", method = RequestMethod.GET) 84 @RequestMapping(value = "/tenant/info/{tenantId}", method = RequestMethod.GET)
75 @ResponseBody 85 @ResponseBody
76 - public TenantInfo getTenantInfoById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { 86 + public TenantInfo getTenantInfoById(
  87 + @ApiParam(value = TENANT_ID_PARAM_DESCRIPTION)
  88 + @PathVariable(TENANT_ID) String strTenantId) throws ThingsboardException {
77 checkParameter(TENANT_ID, strTenantId); 89 checkParameter(TENANT_ID, strTenantId);
78 try { 90 try {
79 TenantId tenantId = new TenantId(toUUID(strTenantId)); 91 TenantId tenantId = new TenantId(toUUID(strTenantId));
@@ -83,10 +95,18 @@ public class TenantController extends BaseController { @@ -83,10 +95,18 @@ public class TenantController extends BaseController {
83 } 95 }
84 } 96 }
85 97
  98 + @ApiOperation(value = "Create Or update Tenant (saveTenant)",
  99 + notes = "Create or update the Tenant. When creating tenant, platform generates Tenant Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
  100 + "Default Rule Chain and Device profile are also generated for the new tenants automatically. " +
  101 + "The newly created Tenant Id will be present in the response. " +
  102 + "Specify existing Tenant Id id to update the Tenant. " +
  103 + "Referencing non-existing Tenant Id will cause 'Not Found' error." + SYSTEM_AUTHORITY_PARAGRAPH)
86 @PreAuthorize("hasAuthority('SYS_ADMIN')") 104 @PreAuthorize("hasAuthority('SYS_ADMIN')")
87 @RequestMapping(value = "/tenant", method = RequestMethod.POST) 105 @RequestMapping(value = "/tenant", method = RequestMethod.POST)
88 @ResponseBody 106 @ResponseBody
89 - public Tenant saveTenant(@RequestBody Tenant tenant) throws ThingsboardException { 107 + public Tenant saveTenant(
  108 + @ApiParam(value = "A JSON value representing the tenant.")
  109 + @RequestBody Tenant tenant) throws ThingsboardException {
90 try { 110 try {
91 boolean newTenant = tenant.getId() == null; 111 boolean newTenant = tenant.getId() == null;
92 112
@@ -107,11 +127,15 @@ public class TenantController extends BaseController { @@ -107,11 +127,15 @@ public class TenantController extends BaseController {
107 } 127 }
108 } 128 }
109 129
  130 + @ApiOperation(value = "Delete Tenant (deleteTenant)",
  131 + notes = "Deletes the tenant, it's customers, rule chains, devices and all other related entities. Referencing non-existing tenant Id will cause an error." + SYSTEM_AUTHORITY_PARAGRAPH)
110 @PreAuthorize("hasAuthority('SYS_ADMIN')") 132 @PreAuthorize("hasAuthority('SYS_ADMIN')")
111 @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.DELETE) 133 @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.DELETE)
112 @ResponseStatus(value = HttpStatus.OK) 134 @ResponseStatus(value = HttpStatus.OK)
113 - public void deleteTenant(@PathVariable("tenantId") String strTenantId) throws ThingsboardException {  
114 - checkParameter("tenantId", strTenantId); 135 + public void deleteTenant(
  136 + @ApiParam(value = TENANT_ID_PARAM_DESCRIPTION)
  137 + @PathVariable(TENANT_ID) String strTenantId) throws ThingsboardException {
  138 + checkParameter(TENANT_ID, strTenantId);
115 try { 139 try {
116 TenantId tenantId = new TenantId(toUUID(strTenantId)); 140 TenantId tenantId = new TenantId(toUUID(strTenantId));
117 Tenant tenant = checkTenantId(tenantId, Operation.DELETE); 141 Tenant tenant = checkTenantId(tenantId, Operation.DELETE);
@@ -124,14 +148,21 @@ public class TenantController extends BaseController { @@ -124,14 +148,21 @@ public class TenantController extends BaseController {
124 } 148 }
125 } 149 }
126 150
  151 + @ApiOperation(value = "Get Tenants (getTenants)", notes = "Returns a page of tenants registered in the platform. " + PAGE_DATA_PARAMETERS + SYSTEM_AUTHORITY_PARAGRAPH)
127 @PreAuthorize("hasAuthority('SYS_ADMIN')") 152 @PreAuthorize("hasAuthority('SYS_ADMIN')")
128 @RequestMapping(value = "/tenants", params = {"pageSize", "page"}, method = RequestMethod.GET) 153 @RequestMapping(value = "/tenants", params = {"pageSize", "page"}, method = RequestMethod.GET)
129 @ResponseBody 154 @ResponseBody
130 - public PageData<Tenant> getTenants(@RequestParam int pageSize,  
131 - @RequestParam int page,  
132 - @RequestParam(required = false) String textSearch,  
133 - @RequestParam(required = false) String sortProperty,  
134 - @RequestParam(required = false) String sortOrder) throws ThingsboardException { 155 + public PageData<Tenant> getTenants(
  156 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
  157 + @RequestParam int pageSize,
  158 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
  159 + @RequestParam int page,
  160 + @ApiParam(value = TENANT_TEXT_SEARCH_DESCRIPTION)
  161 + @RequestParam(required = false) String textSearch,
  162 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = TENANT_SORT_PROPERTY_ALLOWABLE_VALUES)
  163 + @RequestParam(required = false) String sortProperty,
  164 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
  165 + @RequestParam(required = false) String sortOrder) throws ThingsboardException {
135 try { 166 try {
136 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); 167 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
137 return checkNotNull(tenantService.findTenants(pageLink)); 168 return checkNotNull(tenantService.findTenants(pageLink));
@@ -140,14 +171,23 @@ public class TenantController extends BaseController { @@ -140,14 +171,23 @@ public class TenantController extends BaseController {
140 } 171 }
141 } 172 }
142 173
  174 + @ApiOperation(value = "Get Tenants Info (getTenants)", notes = "Returns a page of tenant info objects registered in the platform. "
  175 + + TENANT_INFO_DESCRIPTION + PAGE_DATA_PARAMETERS + SYSTEM_AUTHORITY_PARAGRAPH)
143 @PreAuthorize("hasAuthority('SYS_ADMIN')") 176 @PreAuthorize("hasAuthority('SYS_ADMIN')")
144 @RequestMapping(value = "/tenantInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) 177 @RequestMapping(value = "/tenantInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
145 @ResponseBody 178 @ResponseBody
146 - public PageData<TenantInfo> getTenantInfos(@RequestParam int pageSize,  
147 - @RequestParam int page,  
148 - @RequestParam(required = false) String textSearch,  
149 - @RequestParam(required = false) String sortProperty,  
150 - @RequestParam(required = false) String sortOrder) throws ThingsboardException { 179 + public PageData<TenantInfo> getTenantInfos(
  180 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
  181 + @RequestParam int pageSize,
  182 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
  183 + @RequestParam int page,
  184 + @ApiParam(value = TENANT_TEXT_SEARCH_DESCRIPTION)
  185 + @RequestParam(required = false) String textSearch,
  186 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = TENANT_INFO_SORT_PROPERTY_ALLOWABLE_VALUES)
  187 + @RequestParam(required = false) String sortProperty,
  188 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
  189 + @RequestParam(required = false) String sortOrder
  190 + ) throws ThingsboardException {
151 try { 191 try {
152 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); 192 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
153 return checkNotNull(tenantService.findTenantInfos(pageLink)); 193 return checkNotNull(tenantService.findTenantInfos(pageLink));
@@ -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.springframework.http.HttpStatus; 21 import org.springframework.http.HttpStatus;
20 import org.springframework.security.access.prepost.PreAuthorize; 22 import org.springframework.security.access.prepost.PreAuthorize;
@@ -44,10 +46,16 @@ import org.thingsboard.server.service.security.permission.Resource; @@ -44,10 +46,16 @@ import org.thingsboard.server.service.security.permission.Resource;
44 @Slf4j 46 @Slf4j
45 public class TenantProfileController extends BaseController { 47 public class TenantProfileController extends BaseController {
46 48
  49 + private static final String TENANT_PROFILE_INFO_DESCRIPTION = "Tenant Profile Info is a lightweight object that contains only id and name of the profile. ";
  50 +
  51 + @ApiOperation(value = "Get Tenant Profile (getTenantProfileById)",
  52 + notes = "Fetch the Tenant Profile object based on the provided Tenant Profile Id. " + SYSTEM_AUTHORITY_PARAGRAPH)
47 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')") 53 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')")
48 @RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.GET) 54 @RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.GET)
49 @ResponseBody 55 @ResponseBody
50 - public TenantProfile getTenantProfileById(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { 56 + public TenantProfile getTenantProfileById(
  57 + @ApiParam(value = TENANT_PROFILE_ID_PARAM_DESCRIPTION)
  58 + @PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException {
51 checkParameter("tenantProfileId", strTenantProfileId); 59 checkParameter("tenantProfileId", strTenantProfileId);
52 try { 60 try {
53 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); 61 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId));
@@ -57,10 +65,14 @@ public class TenantProfileController extends BaseController { @@ -57,10 +65,14 @@ public class TenantProfileController extends BaseController {
57 } 65 }
58 } 66 }
59 67
  68 + @ApiOperation(value = "Get Tenant Profile Info (getTenantProfileInfoById)",
  69 + notes = "Fetch the Tenant Profile Info object based on the provided Tenant Profile Id. " + TENANT_PROFILE_INFO_DESCRIPTION + SYSTEM_AUTHORITY_PARAGRAPH)
60 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')") 70 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')")
61 @RequestMapping(value = "/tenantProfileInfo/{tenantProfileId}", method = RequestMethod.GET) 71 @RequestMapping(value = "/tenantProfileInfo/{tenantProfileId}", method = RequestMethod.GET)
62 @ResponseBody 72 @ResponseBody
63 - public EntityInfo getTenantProfileInfoById(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { 73 + public EntityInfo getTenantProfileInfoById(
  74 + @ApiParam(value = TENANT_PROFILE_ID_PARAM_DESCRIPTION)
  75 + @PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException {
64 checkParameter("tenantProfileId", strTenantProfileId); 76 checkParameter("tenantProfileId", strTenantProfileId);
65 try { 77 try {
66 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); 78 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId));
@@ -70,6 +82,8 @@ public class TenantProfileController extends BaseController { @@ -70,6 +82,8 @@ public class TenantProfileController extends BaseController {
70 } 82 }
71 } 83 }
72 84
  85 + @ApiOperation(value = "Get default Tenant Profile Info (getDefaultTenantProfileInfo)",
  86 + notes = "Fetch the default Tenant Profile Info object based. " + TENANT_PROFILE_INFO_DESCRIPTION + SYSTEM_AUTHORITY_PARAGRAPH)
73 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')") 87 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')")
74 @RequestMapping(value = "/tenantProfileInfo/default", method = RequestMethod.GET) 88 @RequestMapping(value = "/tenantProfileInfo/default", method = RequestMethod.GET)
75 @ResponseBody 89 @ResponseBody
@@ -81,10 +95,19 @@ public class TenantProfileController extends BaseController { @@ -81,10 +95,19 @@ public class TenantProfileController extends BaseController {
81 } 95 }
82 } 96 }
83 97
  98 + @ApiOperation(value = "Create Or update Tenant Profile (saveTenantProfile)",
  99 + notes = "Create or update the Tenant Profile. When creating tenant profile, platform generates Tenant Profile Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
  100 + "The newly created Tenant Profile Id will be present in the response. " +
  101 + "Specify existing Tenant Profile Id id to update the Tenant Profile. " +
  102 + "Referencing non-existing Tenant Profile Id will cause 'Not Found' error. " +
  103 + "Update of the tenant profile configuration will cause immediate recalculation of API limits for all affected Tenants. " +
  104 + SYSTEM_AUTHORITY_PARAGRAPH)
84 @PreAuthorize("hasAuthority('SYS_ADMIN')") 105 @PreAuthorize("hasAuthority('SYS_ADMIN')")
85 @RequestMapping(value = "/tenantProfile", method = RequestMethod.POST) 106 @RequestMapping(value = "/tenantProfile", method = RequestMethod.POST)
86 @ResponseBody 107 @ResponseBody
87 - public TenantProfile saveTenantProfile(@RequestBody TenantProfile tenantProfile) throws ThingsboardException { 108 + public TenantProfile saveTenantProfile(
  109 + @ApiParam(value = "A JSON value representing the tenant profile.")
  110 + @RequestBody TenantProfile tenantProfile) throws ThingsboardException {
88 try { 111 try {
89 boolean newTenantProfile = tenantProfile.getId() == null; 112 boolean newTenantProfile = tenantProfile.getId() == null;
90 if (newTenantProfile) { 113 if (newTenantProfile) {
@@ -105,10 +128,14 @@ public class TenantProfileController extends BaseController { @@ -105,10 +128,14 @@ public class TenantProfileController extends BaseController {
105 } 128 }
106 } 129 }
107 130
  131 + @ApiOperation(value = "Delete Tenant Profile (deleteTenantProfile)",
  132 + notes = "Deletes the tenant profile. Referencing non-existing tenant profile Id will cause an error. Referencing profile that is used by the tenants will cause an error. " + SYSTEM_AUTHORITY_PARAGRAPH)
108 @PreAuthorize("hasAuthority('SYS_ADMIN')") 133 @PreAuthorize("hasAuthority('SYS_ADMIN')")
109 @RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.DELETE) 134 @RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.DELETE)
110 @ResponseStatus(value = HttpStatus.OK) 135 @ResponseStatus(value = HttpStatus.OK)
111 - public void deleteTenantProfile(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { 136 + public void deleteTenantProfile(
  137 + @ApiParam(value = TENANT_PROFILE_ID_PARAM_DESCRIPTION)
  138 + @PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException {
112 checkParameter("tenantProfileId", strTenantProfileId); 139 checkParameter("tenantProfileId", strTenantProfileId);
113 try { 140 try {
114 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); 141 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId));
@@ -120,10 +147,14 @@ public class TenantProfileController extends BaseController { @@ -120,10 +147,14 @@ public class TenantProfileController extends BaseController {
120 } 147 }
121 } 148 }
122 149
  150 + @ApiOperation(value = "Make tenant profile default (setDefaultTenantProfile)",
  151 + notes = "Makes specified tenant profile to be default. Referencing non-existing tenant profile Id will cause an error. " + SYSTEM_AUTHORITY_PARAGRAPH)
123 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')") 152 @PreAuthorize("hasAnyAuthority('SYS_ADMIN')")
124 @RequestMapping(value = "/tenantProfile/{tenantProfileId}/default", method = RequestMethod.POST) 153 @RequestMapping(value = "/tenantProfile/{tenantProfileId}/default", method = RequestMethod.POST)
125 @ResponseBody 154 @ResponseBody
126 - public TenantProfile setDefaultTenantProfile(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { 155 + public TenantProfile setDefaultTenantProfile(
  156 + @ApiParam(value = TENANT_PROFILE_ID_PARAM_DESCRIPTION)
  157 + @PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException {
127 checkParameter("tenantProfileId", strTenantProfileId); 158 checkParameter("tenantProfileId", strTenantProfileId);
128 try { 159 try {
129 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); 160 TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId));
@@ -135,14 +166,21 @@ public class TenantProfileController extends BaseController { @@ -135,14 +166,21 @@ public class TenantProfileController extends BaseController {
135 } 166 }
136 } 167 }
137 168
  169 + @ApiOperation(value = "Get Tenant Profiles (getTenantProfiles)", notes = "Returns a page of tenant profiles registered in the platform. " + PAGE_DATA_PARAMETERS + SYSTEM_AUTHORITY_PARAGRAPH)
138 @PreAuthorize("hasAuthority('SYS_ADMIN')") 170 @PreAuthorize("hasAuthority('SYS_ADMIN')")
139 @RequestMapping(value = "/tenantProfiles", params = {"pageSize", "page"}, method = RequestMethod.GET) 171 @RequestMapping(value = "/tenantProfiles", params = {"pageSize", "page"}, method = RequestMethod.GET)
140 @ResponseBody 172 @ResponseBody
141 - public PageData<TenantProfile> getTenantProfiles(@RequestParam int pageSize,  
142 - @RequestParam int page,  
143 - @RequestParam(required = false) String textSearch,  
144 - @RequestParam(required = false) String sortProperty,  
145 - @RequestParam(required = false) String sortOrder) throws ThingsboardException { 173 + public PageData<TenantProfile> getTenantProfiles(
  174 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
  175 + @RequestParam int pageSize,
  176 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
  177 + @RequestParam int page,
  178 + @ApiParam(value = TENANT_PROFILE_TEXT_SEARCH_DESCRIPTION)
  179 + @RequestParam(required = false) String textSearch,
  180 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = TENANT_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES)
  181 + @RequestParam(required = false) String sortProperty,
  182 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
  183 + @RequestParam(required = false) String sortOrder) throws ThingsboardException {
146 try { 184 try {
147 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); 185 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
148 return checkNotNull(tenantProfileService.findTenantProfiles(getTenantId(), pageLink)); 186 return checkNotNull(tenantProfileService.findTenantProfiles(getTenantId(), pageLink));
@@ -151,14 +189,22 @@ public class TenantProfileController extends BaseController { @@ -151,14 +189,22 @@ public class TenantProfileController extends BaseController {
151 } 189 }
152 } 190 }
153 191
  192 + @ApiOperation(value = "Get Tenant Profiles Info (getTenantProfileInfos)", notes = "Returns a page of tenant profile info objects registered in the platform. "
  193 + + TENANT_PROFILE_INFO_DESCRIPTION + PAGE_DATA_PARAMETERS + SYSTEM_AUTHORITY_PARAGRAPH)
154 @PreAuthorize("hasAuthority('SYS_ADMIN')") 194 @PreAuthorize("hasAuthority('SYS_ADMIN')")
155 @RequestMapping(value = "/tenantProfileInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) 195 @RequestMapping(value = "/tenantProfileInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
156 @ResponseBody 196 @ResponseBody
157 - public PageData<EntityInfo> getTenantProfileInfos(@RequestParam int pageSize,  
158 - @RequestParam int page,  
159 - @RequestParam(required = false) String textSearch,  
160 - @RequestParam(required = false) String sortProperty,  
161 - @RequestParam(required = false) String sortOrder) throws ThingsboardException { 197 + public PageData<EntityInfo> getTenantProfileInfos(
  198 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
  199 + @RequestParam int pageSize,
  200 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
  201 + @RequestParam int page,
  202 + @ApiParam(value = TENANT_PROFILE_TEXT_SEARCH_DESCRIPTION)
  203 + @RequestParam(required = false) String textSearch,
  204 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = TENANT_PROFILE_INFO_SORT_PROPERTY_ALLOWABLE_VALUES)
  205 + @RequestParam(required = false) String sortProperty,
  206 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
  207 + @RequestParam(required = false) String sortOrder) throws ThingsboardException {
162 try { 208 try {
163 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); 209 PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
164 return checkNotNull(tenantProfileService.findTenantProfileInfos(getTenantId(), pageLink)); 210 return checkNotNull(tenantProfileService.findTenantProfileInfos(getTenantId(), pageLink));
@@ -18,6 +18,8 @@ package org.thingsboard.server.common.data; @@ -18,6 +18,8 @@ package org.thingsboard.server.common.data;
18 import com.fasterxml.jackson.annotation.JsonIgnore; 18 import com.fasterxml.jackson.annotation.JsonIgnore;
19 import com.fasterxml.jackson.annotation.JsonProperty; 19 import com.fasterxml.jackson.annotation.JsonProperty;
20 import com.fasterxml.jackson.annotation.JsonProperty.Access; 20 import com.fasterxml.jackson.annotation.JsonProperty.Access;
  21 +import com.fasterxml.jackson.databind.JsonNode;
  22 +import io.swagger.annotations.ApiModelProperty;
21 import org.thingsboard.server.common.data.id.CustomerId; 23 import org.thingsboard.server.common.data.id.CustomerId;
22 import org.thingsboard.server.common.data.id.TenantId; 24 import org.thingsboard.server.common.data.id.TenantId;
23 import org.thingsboard.server.common.data.validation.NoXss; 25 import org.thingsboard.server.common.data.validation.NoXss;
@@ -27,7 +29,9 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId { @@ -27,7 +29,9 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId {
27 private static final long serialVersionUID = -1599722990298929275L; 29 private static final long serialVersionUID = -1599722990298929275L;
28 30
29 @NoXss 31 @NoXss
  32 + @ApiModelProperty(position = 3, value = "Title of the customer", example = "Company A")
30 private String title; 33 private String title;
  34 + @ApiModelProperty(position = 5, required = true, value = "JSON object with Tenant Id")
31 private TenantId tenantId; 35 private TenantId tenantId;
32 36
33 public Customer() { 37 public Customer() {
@@ -51,7 +55,7 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId { @@ -51,7 +55,7 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId {
51 public void setTenantId(TenantId tenantId) { 55 public void setTenantId(TenantId tenantId) {
52 this.tenantId = tenantId; 56 this.tenantId = tenantId;
53 } 57 }
54 - 58 +
55 public String getTitle() { 59 public String getTitle() {
56 return title; 60 return title;
57 } 61 }
@@ -60,6 +64,75 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId { @@ -60,6 +64,75 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId {
60 this.title = title; 64 this.title = title;
61 } 65 }
62 66
  67 + @ApiModelProperty(position = 1, value = "JSON object with the customer Id. " +
  68 + "Specify this field to update the customer. " +
  69 + "Referencing non-existing customer Id will cause error. " +
  70 + "Omit this field to create new customer." )
  71 + @Override
  72 + public CustomerId getId() {
  73 + return super.getId();
  74 + }
  75 +
  76 + @ApiModelProperty(position = 2, value = "Timestamp of the customer creation, in milliseconds", example = "1609459200000", readOnly = true)
  77 + @Override
  78 + public long getCreatedTime() {
  79 + return super.getCreatedTime();
  80 + }
  81 +
  82 + @ApiModelProperty(position = 6, required = true, value = "Country", example = "US")
  83 + @Override
  84 + public String getCountry() {
  85 + return super.getCountry();
  86 + }
  87 +
  88 + @ApiModelProperty(position = 7, required = true, value = "State", example = "NY")
  89 + @Override
  90 + public String getState() {
  91 + return super.getState();
  92 + }
  93 +
  94 + @ApiModelProperty(position = 8, required = true, value = "City", example = "New York")
  95 + @Override
  96 + public String getCity() {
  97 + return super.getCity();
  98 + }
  99 +
  100 + @ApiModelProperty(position = 9, required = true, value = "Address Line 1", example = "42 Broadway Suite 12-400")
  101 + @Override
  102 + public String getAddress() {
  103 + return super.getAddress();
  104 + }
  105 +
  106 + @ApiModelProperty(position = 10, required = true, value = "Address Line 2", example = "")
  107 + @Override
  108 + public String getAddress2() {
  109 + return super.getAddress2();
  110 + }
  111 +
  112 + @ApiModelProperty(position = 11, required = true, value = "Zip code", example = "10004")
  113 + @Override
  114 + public String getZip() {
  115 + return super.getZip();
  116 + }
  117 +
  118 + @ApiModelProperty(position = 12, required = true, value = "Phone number", example = "+1(415)777-7777")
  119 + @Override
  120 + public String getPhone() {
  121 + return super.getPhone();
  122 + }
  123 +
  124 + @ApiModelProperty(position = 13, required = true, value = "Email", example = "example@company.com")
  125 + @Override
  126 + public String getEmail() {
  127 + return super.getEmail();
  128 + }
  129 +
  130 + @ApiModelProperty(position = 14, value = "Additional parameters of the device", dataType = "com.fasterxml.jackson.databind.JsonNode")
  131 + @Override
  132 + public JsonNode getAdditionalInfo() {
  133 + return super.getAdditionalInfo();
  134 + }
  135 +
63 @JsonIgnore 136 @JsonIgnore
64 public boolean isPublic() { 137 public boolean isPublic() {
65 if (getAdditionalInfo() != null && getAdditionalInfo().has("isPublic")) { 138 if (getAdditionalInfo() != null && getAdditionalInfo().has("isPublic")) {
@@ -76,6 +149,7 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId { @@ -76,6 +149,7 @@ public class Customer extends ContactBased<CustomerId> implements HasTenantId {
76 149
77 @Override 150 @Override
78 @JsonProperty(access = Access.READ_ONLY) 151 @JsonProperty(access = Access.READ_ONLY)
  152 + @ApiModelProperty(position = 4, value = "Name of the customer. Read-only, duplicated from title for backward compatibility", example = "Company A", readOnly = true)
79 public String getName() { 153 public String getName() {
80 return title; 154 return title;
81 } 155 }
@@ -17,6 +17,7 @@ package org.thingsboard.server.common.data; @@ -17,6 +17,7 @@ package org.thingsboard.server.common.data;
17 17
18 import com.fasterxml.jackson.annotation.JsonCreator; 18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonProperty; 19 import com.fasterxml.jackson.annotation.JsonProperty;
  20 +import io.swagger.annotations.ApiModelProperty;
20 import lombok.EqualsAndHashCode; 21 import lombok.EqualsAndHashCode;
21 import lombok.ToString; 22 import lombok.ToString;
22 import lombok.Value; 23 import lombok.Value;
@@ -31,9 +32,13 @@ import java.util.UUID; @@ -31,9 +32,13 @@ import java.util.UUID;
31 @ToString(callSuper = true) 32 @ToString(callSuper = true)
32 public class DeviceProfileInfo extends EntityInfo { 33 public class DeviceProfileInfo extends EntityInfo {
33 34
  35 + @ApiModelProperty(position = 3, value = "Either URL or Base64 data of the icon. Used in the mobile application to visualize set of device profiles in the grid view. ")
34 private final String image; 36 private final String image;
  37 + @ApiModelProperty(position = 4, value = "Reference to the dashboard. Used in the mobile application to open the default dashboard when user navigates to device details.")
35 private final DashboardId defaultDashboardId; 38 private final DashboardId defaultDashboardId;
  39 + @ApiModelProperty(position = 5, value = "Type of the profile. Always 'DEFAULT' for now. Reserved for future use.")
36 private final DeviceProfileType type; 40 private final DeviceProfileType type;
  41 + @ApiModelProperty(position = 6, value = "Type of the transport used to connect the device. Default transport supports HTTP, CoAP and MQTT.")
37 private final DeviceTransportType transportType; 42 private final DeviceTransportType transportType;
38 43
39 @JsonCreator 44 @JsonCreator
@@ -17,6 +17,8 @@ package org.thingsboard.server.common.data; @@ -17,6 +17,8 @@ package org.thingsboard.server.common.data;
17 17
18 import com.fasterxml.jackson.annotation.JsonCreator; 18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonProperty; 19 import com.fasterxml.jackson.annotation.JsonProperty;
  20 +import io.swagger.annotations.ApiModel;
  21 +import io.swagger.annotations.ApiModelProperty;
20 import lombok.Data; 22 import lombok.Data;
21 import org.thingsboard.server.common.data.id.EntityId; 23 import org.thingsboard.server.common.data.id.EntityId;
22 import org.thingsboard.server.common.data.id.EntityIdFactory; 24 import org.thingsboard.server.common.data.id.EntityIdFactory;
@@ -24,10 +26,13 @@ import org.thingsboard.server.common.data.id.HasId; @@ -24,10 +26,13 @@ import org.thingsboard.server.common.data.id.HasId;
24 26
25 import java.util.UUID; 27 import java.util.UUID;
26 28
  29 +@ApiModel
27 @Data 30 @Data
28 public class EntityInfo implements HasId<EntityId>, HasName { 31 public class EntityInfo implements HasId<EntityId>, HasName {
29 32
  33 + @ApiModelProperty(position = 1, value = "JSON object with the entity Id. ")
30 private final EntityId id; 34 private final EntityId id;
  35 + @ApiModelProperty(position = 2, value = "Entity Name")
31 private final String name; 36 private final String name;
32 37
33 @JsonCreator 38 @JsonCreator
@@ -17,20 +17,28 @@ package org.thingsboard.server.common.data; @@ -17,20 +17,28 @@ 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.annotation.JsonProperty; 19 import com.fasterxml.jackson.annotation.JsonProperty;
  20 +import com.fasterxml.jackson.databind.JsonNode;
  21 +import io.swagger.annotations.ApiModel;
  22 +import io.swagger.annotations.ApiModelProperty;
20 import lombok.EqualsAndHashCode; 23 import lombok.EqualsAndHashCode;
21 import org.thingsboard.server.common.data.id.TenantId; 24 import org.thingsboard.server.common.data.id.TenantId;
22 import org.thingsboard.server.common.data.id.TenantProfileId; 25 import org.thingsboard.server.common.data.id.TenantProfileId;
23 import org.thingsboard.server.common.data.validation.NoXss; 26 import org.thingsboard.server.common.data.validation.NoXss;
24 27
  28 +@ApiModel
25 @EqualsAndHashCode(callSuper = true) 29 @EqualsAndHashCode(callSuper = true)
26 public class Tenant extends ContactBased<TenantId> implements HasTenantId { 30 public class Tenant extends ContactBased<TenantId> implements HasTenantId {
27 31
28 private static final long serialVersionUID = 8057243243859922101L; 32 private static final long serialVersionUID = 8057243243859922101L;
29 33
30 @NoXss 34 @NoXss
  35 + @ApiModelProperty(position = 3, value = "Title of the tenant", example = "Company A")
31 private String title; 36 private String title;
32 @NoXss 37 @NoXss
  38 + @ApiModelProperty(position = 5, value = "Geo region of the tenant", example = "North America")
33 private String region; 39 private String region;
  40 +
  41 + @ApiModelProperty(position = 6, required = true, value = "JSON object with Tenant Profile Id")
34 private TenantProfileId tenantProfileId; 42 private TenantProfileId tenantProfileId;
35 43
36 public Tenant() { 44 public Tenant() {
@@ -63,6 +71,7 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId { @@ -63,6 +71,7 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId {
63 } 71 }
64 72
65 @Override 73 @Override
  74 + @ApiModelProperty(position = 4, value = "Name of the tenant. Read-only, duplicated from title for backward compatibility", example = "Company A", readOnly = true)
66 @JsonProperty(access = JsonProperty.Access.READ_ONLY) 75 @JsonProperty(access = JsonProperty.Access.READ_ONLY)
67 public String getName() { 76 public String getName() {
68 return title; 77 return title;
@@ -89,6 +98,75 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId { @@ -89,6 +98,75 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId {
89 return getTitle(); 98 return getTitle();
90 } 99 }
91 100
  101 + @ApiModelProperty(position = 1, value = "JSON object with the tenant Id. " +
  102 + "Specify this field to update the tenant. " +
  103 + "Referencing non-existing tenant Id will cause error. " +
  104 + "Omit this field to create new tenant." )
  105 + @Override
  106 + public TenantId getId() {
  107 + return super.getId();
  108 + }
  109 +
  110 + @ApiModelProperty(position = 2, value = "Timestamp of the tenant creation, in milliseconds", example = "1609459200000", readOnly = true)
  111 + @Override
  112 + public long getCreatedTime() {
  113 + return super.getCreatedTime();
  114 + }
  115 +
  116 + @ApiModelProperty(position = 7, required = true, value = "Country", example = "US")
  117 + @Override
  118 + public String getCountry() {
  119 + return super.getCountry();
  120 + }
  121 +
  122 + @ApiModelProperty(position = 8, required = true, value = "State", example = "NY")
  123 + @Override
  124 + public String getState() {
  125 + return super.getState();
  126 + }
  127 +
  128 + @ApiModelProperty(position = 9, required = true, value = "City", example = "New York")
  129 + @Override
  130 + public String getCity() {
  131 + return super.getCity();
  132 + }
  133 +
  134 + @ApiModelProperty(position = 10, required = true, value = "Address Line 1", example = "42 Broadway Suite 12-400")
  135 + @Override
  136 + public String getAddress() {
  137 + return super.getAddress();
  138 + }
  139 +
  140 + @ApiModelProperty(position = 11, required = true, value = "Address Line 2", example = "")
  141 + @Override
  142 + public String getAddress2() {
  143 + return super.getAddress2();
  144 + }
  145 +
  146 + @ApiModelProperty(position = 12, required = true, value = "Zip code", example = "10004")
  147 + @Override
  148 + public String getZip() {
  149 + return super.getZip();
  150 + }
  151 +
  152 + @ApiModelProperty(position = 13, required = true, value = "Phone number", example = "+1(415)777-7777")
  153 + @Override
  154 + public String getPhone() {
  155 + return super.getPhone();
  156 + }
  157 +
  158 + @ApiModelProperty(position = 14, required = true, value = "Email", example = "example@company.com")
  159 + @Override
  160 + public String getEmail() {
  161 + return super.getEmail();
  162 + }
  163 +
  164 + @ApiModelProperty(position = 15, value = "Additional parameters of the device", dataType = "com.fasterxml.jackson.databind.JsonNode")
  165 + @Override
  166 + public JsonNode getAdditionalInfo() {
  167 + return super.getAdditionalInfo();
  168 + }
  169 +
92 @Override 170 @Override
93 public String toString() { 171 public String toString() {
94 StringBuilder builder = new StringBuilder(); 172 StringBuilder builder = new StringBuilder();
@@ -15,12 +15,15 @@ @@ -15,12 +15,15 @@
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 org.thingsboard.server.common.data.id.TenantId; 21 import org.thingsboard.server.common.data.id.TenantId;
20 22
  23 +@ApiModel
21 @Data 24 @Data
22 public class TenantInfo extends Tenant { 25 public class TenantInfo extends Tenant {
23 - 26 + @ApiModelProperty(position = 15, value = "Tenant Profile name", example = "Default")
24 private String tenantProfileName; 27 private String tenantProfileName;
25 28
26 public TenantInfo() { 29 public TenantInfo() {
@@ -17,6 +17,8 @@ package org.thingsboard.server.common.data; @@ -17,6 +17,8 @@ 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.core.JsonProcessingException; 19 import com.fasterxml.jackson.core.JsonProcessingException;
  20 +import io.swagger.annotations.ApiModel;
  21 +import io.swagger.annotations.ApiModelProperty;
20 import lombok.Data; 22 import lombok.Data;
21 import lombok.EqualsAndHashCode; 23 import lombok.EqualsAndHashCode;
22 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
@@ -31,18 +33,27 @@ import java.util.Optional; @@ -31,18 +33,27 @@ import java.util.Optional;
31 33
32 import static org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo.mapper; 34 import static org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo.mapper;
33 35
  36 +@ApiModel
34 @Data 37 @Data
35 @EqualsAndHashCode(callSuper = true) 38 @EqualsAndHashCode(callSuper = true)
36 @Slf4j 39 @Slf4j
37 public class TenantProfile extends SearchTextBased<TenantProfileId> implements HasName { 40 public class TenantProfile extends SearchTextBased<TenantProfileId> implements HasName {
38 41
39 @NoXss 42 @NoXss
  43 + @ApiModelProperty(position = 3, value = "Name of the tenant profile", example = "High Priority Tenants")
40 private String name; 44 private String name;
41 @NoXss 45 @NoXss
  46 + @ApiModelProperty(position = 4, value = "Description of the tenant profile", example = "Any text")
42 private String description; 47 private String description;
  48 + @ApiModelProperty(position = 5, value = "Default Tenant profile to be used.", example = "true")
43 private boolean isDefault; 49 private boolean isDefault;
  50 + @ApiModelProperty(position = 6, value = "If enabled, will push all messages related to this tenant and processed by core platform services into separate queue. " +
  51 + "Useful for complex microservices deployments, to isolate processing of the data for specific tenants", example = "true")
44 private boolean isolatedTbCore; 52 private boolean isolatedTbCore;
  53 + @ApiModelProperty(position = 7, value = "If enabled, will push all messages related to this tenant and processed by the rule engine into separate queue. " +
  54 + "Useful for complex microservices deployments, to isolate processing of the data for specific tenants", example = "true")
45 private boolean isolatedTbRuleEngine; 55 private boolean isolatedTbRuleEngine;
  56 + @ApiModelProperty(position = 8, value = "Complex JSON object that contains profile settings: max devices, max assets, rate limits, etc.")
46 private transient TenantProfileData profileData; 57 private transient TenantProfileData profileData;
47 @JsonIgnore 58 @JsonIgnore
48 private byte[] profileDataBytes; 59 private byte[] profileDataBytes;
@@ -65,6 +76,21 @@ public class TenantProfile extends SearchTextBased<TenantProfileId> implements H @@ -65,6 +76,21 @@ public class TenantProfile extends SearchTextBased<TenantProfileId> implements H
65 this.setProfileData(tenantProfile.getProfileData()); 76 this.setProfileData(tenantProfile.getProfileData());
66 } 77 }
67 78
  79 + @ApiModelProperty(position = 1, value = "JSON object with the tenant profile Id. " +
  80 + "Specify this field to update the tenant profile. " +
  81 + "Referencing non-existing tenant profile Id will cause error. " +
  82 + "Omit this field to create new tenant profile." )
  83 + @Override
  84 + public TenantProfileId getId() {
  85 + return super.getId();
  86 + }
  87 +
  88 + @ApiModelProperty(position = 2, value = "Timestamp of the tenant profile creation, in milliseconds", example = "1609459200000", readOnly = true)
  89 + @Override
  90 + public long getCreatedTime() {
  91 + return super.getCreatedTime();
  92 + }
  93 +
68 @Override 94 @Override
69 public String getSearchText() { 95 public String getSearchText() {
70 return getName(); 96 return getName();
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.tenant.profile; 16 package org.thingsboard.server.common.data.tenant.profile;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.AllArgsConstructor; 20 import lombok.AllArgsConstructor;
19 import lombok.Builder; 21 import lombok.Builder;
20 import lombok.Data; 22 import lombok.Data;
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
19 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 19 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20 import com.fasterxml.jackson.annotation.JsonSubTypes; 20 import com.fasterxml.jackson.annotation.JsonSubTypes;
21 import com.fasterxml.jackson.annotation.JsonTypeInfo; 21 import com.fasterxml.jackson.annotation.JsonTypeInfo;
  22 +import io.swagger.annotations.ApiModel;
22 import org.thingsboard.server.common.data.ApiUsageRecordKey; 23 import org.thingsboard.server.common.data.ApiUsageRecordKey;
23 import org.thingsboard.server.common.data.TenantProfileType; 24 import org.thingsboard.server.common.data.TenantProfileType;
24 25
@@ -15,11 +15,15 @@ @@ -15,11 +15,15 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.tenant.profile; 16 package org.thingsboard.server.common.data.tenant.profile;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 20 import lombok.Data;
19 21
  22 +@ApiModel
20 @Data 23 @Data
21 public class TenantProfileData { 24 public class TenantProfileData {
22 25
  26 + @ApiModelProperty(position = 1, value = "Complex JSON object that contains profile settings: max devices, max assets, rate limits, etc.")
23 private TenantProfileConfiguration configuration; 27 private TenantProfileConfiguration configuration;
24 28
25 } 29 }