Improve swagger description for SaveAttributes
This commit is contained in:
		
							parent
							
								
									a0091c632a
								
							
						
					
					
						commit
						89bb6cafce
					
				@ -1433,7 +1433,8 @@ public class ControllerConstants {
 | 
			
		||||
 | 
			
		||||
    protected static final String ATTRIBUTES_SCOPE_DESCRIPTION = "A string value representing the attributes scope. For example, 'SERVER_SCOPE'.";
 | 
			
		||||
    protected static final String ATTRIBUTES_KEYS_DESCRIPTION = "A string value representing the comma-separated list of attributes keys. For example, 'active,inactivityAlarmTime'.";
 | 
			
		||||
    protected static final String ATTRIBUTES_SCOPE_ALLOWED_VALUES = "SERVER_SCOPE, CLIENT_SCOPE, SHARED_SCOPE";
 | 
			
		||||
    protected static final String ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES = "SERVER_SCOPE, SHARED_SCOPE";
 | 
			
		||||
    protected static final String ATTRIBUTES_SCOPE_ALLOWED_VALUES = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES + ", CLIENT_SCOPE";
 | 
			
		||||
    protected static final String ATTRIBUTES_JSON_REQUEST_DESCRIPTION = "A string value representing the json object. For example, '{\"key\":\"value\"}'. See API call description for more details.";
 | 
			
		||||
 | 
			
		||||
    protected static final String TELEMETRY_KEYS_BASE_DESCRIPTION = "A string value representing the comma-separated list of telemetry keys.";
 | 
			
		||||
@ -1459,10 +1460,12 @@ public class ControllerConstants {
 | 
			
		||||
    protected static final String SAVE_ENTITY_TIMESERIES_STATUS_INTERNAL_SERVER_ERROR = "The exception was thrown during processing the request. " +
 | 
			
		||||
            "Platform creates an audit log event about entity timeseries updates with action type 'TIMESERIES_UPDATED' that includes an error stacktrace.";
 | 
			
		||||
 | 
			
		||||
    protected static final String ENTITY_ATTRIBUTE_SCOPES = " List of possible attribute scopes depends on the entity type: " +
 | 
			
		||||
    protected static final String ENTITY_ATTRIBUTE_SCOPES_TEMPLATE = " List of possible attribute scopes depends on the entity type: " +
 | 
			
		||||
            "\n\n * SERVER_SCOPE - supported for all entity types;" +
 | 
			
		||||
            "\n * CLIENT_SCOPE - supported for devices;" +
 | 
			
		||||
            "\n * SHARED_SCOPE - supported for devices. "+ "\n\n";
 | 
			
		||||
            "\n * SHARED_SCOPE - supported for devices";
 | 
			
		||||
    protected static final String ENTITY_SAVE_ATTRIBUTE_SCOPES = ENTITY_ATTRIBUTE_SCOPES_TEMPLATE + ".\n\n";
 | 
			
		||||
    protected static final String ENTITY_GET_ATTRIBUTE_SCOPES = ENTITY_ATTRIBUTE_SCOPES_TEMPLATE +
 | 
			
		||||
            ";\n * CLIENT_SCOPE - supported for devices. " + "\n\n";
 | 
			
		||||
 | 
			
		||||
    protected static final String ATTRIBUTE_DATA_EXAMPLE = "[\n" +
 | 
			
		||||
            "  {\"key\": \"stringAttributeKey\", \"value\": \"value\", \"lastUpdateTs\": 1609459200000},\n" +
 | 
			
		||||
 | 
			
		||||
@ -58,7 +58,6 @@ import org.thingsboard.server.common.data.id.EntityIdFactory;
 | 
			
		||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.UUIDBased;
 | 
			
		||||
import org.thingsboard.server.common.data.kv.Aggregation;
 | 
			
		||||
import org.thingsboard.server.common.data.kv.AttributeKey;
 | 
			
		||||
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
 | 
			
		||||
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
 | 
			
		||||
import org.thingsboard.server.common.data.kv.BaseDeleteTsKvQuery;
 | 
			
		||||
@ -92,11 +91,9 @@ import javax.annotation.PostConstruct;
 | 
			
		||||
import javax.annotation.PreDestroy;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.ExecutorService;
 | 
			
		||||
import java.util.concurrent.Executors;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
@ -104,13 +101,15 @@ import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_JSON_REQUEST_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_KEYS_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SCOPE_ALLOWED_VALUES;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SCOPE_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTE_DATA_EXAMPLE;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.DEVICE_ID;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.DEVICE_ID_PARAM_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ENTITY_ATTRIBUTE_SCOPES;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ENTITY_GET_ATTRIBUTE_SCOPES;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ENTITY_ID_PARAM_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ENTITY_SAVE_ATTRIBUTE_SCOPES;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.ENTITY_TYPE_PARAM_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION;
 | 
			
		||||
import static org.thingsboard.server.controller.ControllerConstants.INVALID_STRUCTURE_OF_THE_REQUEST;
 | 
			
		||||
@ -241,7 +240,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "Get attributes by scope (getAttributesByScope)",
 | 
			
		||||
            notes = "Returns all attributes of a specified scope that belong to specified entity." +
 | 
			
		||||
                    ENTITY_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    ENTITY_GET_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    "Use optional 'keys' parameter to return specific attributes."
 | 
			
		||||
                    + "\n Example of the result: \n\n"
 | 
			
		||||
                    + MARKDOWN_CODE_BLOCK_START
 | 
			
		||||
@ -383,7 +382,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public DeferredResult<ResponseEntity> saveDeviceAttributes(
 | 
			
		||||
            @ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION, required = true) @PathVariable("deviceId") String deviceIdStr,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException {
 | 
			
		||||
        try {
 | 
			
		||||
            EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr);
 | 
			
		||||
@ -395,7 +394,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "Save entity attributes (saveEntityAttributesV1)",
 | 
			
		||||
            notes = "Creates or updates the entity attributes based on Entity Id and the specified attribute scope. " +
 | 
			
		||||
                    ENTITY_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    ENTITY_SAVE_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    SAVE_ATTRIBUTES_REQUEST_PAYLOAD
 | 
			
		||||
                    + INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
 | 
			
		||||
            produces = MediaType.APPLICATION_JSON_VALUE)
 | 
			
		||||
@ -411,7 +410,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
    public DeferredResult<ResponseEntity> saveEntityAttributesV1(
 | 
			
		||||
            @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, defaultValue = "DEVICE") @PathVariable("entityType") String entityType,
 | 
			
		||||
            @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException {
 | 
			
		||||
        try {
 | 
			
		||||
            EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
 | 
			
		||||
@ -423,7 +422,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "Save entity attributes (saveEntityAttributesV2)",
 | 
			
		||||
            notes = "Creates or updates the entity attributes based on Entity Id and the specified attribute scope. " +
 | 
			
		||||
                    ENTITY_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    ENTITY_SAVE_ATTRIBUTE_SCOPES +
 | 
			
		||||
                    SAVE_ATTRIBUTES_REQUEST_PAYLOAD
 | 
			
		||||
                    + INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
 | 
			
		||||
            produces = MediaType.APPLICATION_JSON_VALUE)
 | 
			
		||||
@ -439,7 +438,7 @@ public class TelemetryController extends BaseController {
 | 
			
		||||
    public DeferredResult<ResponseEntity> saveEntityAttributesV2(
 | 
			
		||||
            @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, defaultValue = "DEVICE") @PathVariable("entityType") String entityType,
 | 
			
		||||
            @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope,
 | 
			
		||||
            @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException {
 | 
			
		||||
        try {
 | 
			
		||||
            EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user