Refactor tenant configuration management (#2840)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.mgmt.rest.api;
|
||||
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TENANT_ORDER;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -28,6 +26,7 @@ import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationV
|
||||
import org.eclipse.hawkbit.rest.OpenApi;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -35,6 +34,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* REST Resource for handling tenant specific configuration operations.
|
||||
@@ -74,38 +74,6 @@ public interface MgmtTenantManagementRestApi {
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getTenantConfiguration();
|
||||
|
||||
/**
|
||||
* Handles the DELETE request of deleting a tenant specific configuration value.
|
||||
*
|
||||
* @param keyName the Name of the configuration key
|
||||
* @return if the given configuration value exists and could be deleted HTTP OK. In any failure the JsonResponseExceptionHandler is handling
|
||||
* the response.
|
||||
*/
|
||||
@Operation(summary = "Delete a tenant specific configuration value", description = "The DELETE request removes a " +
|
||||
"tenant specific configuration value for the tenant. Afterwards the global default value is used. " +
|
||||
"Required Permission: TENANT_CONFIGURATION")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "204", description = "Successfully deleted"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
|
||||
@ApiResponse(responseCode = "401", description = "The request requires user auth.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "403",
|
||||
description = "Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or " +
|
||||
"data volume restriction applies.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
|
||||
"and the client has to wait another second.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
||||
})
|
||||
@DeleteMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<Void> deleteTenantConfigurationValue(@PathVariable("keyName") String keyName);
|
||||
|
||||
/**
|
||||
* Handles the GET request of receiving a tenant specific configuration value.
|
||||
*
|
||||
@@ -138,16 +106,13 @@ public interface MgmtTenantManagementRestApi {
|
||||
})
|
||||
@GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<MgmtSystemTenantConfigurationValue> getTenantConfigurationValue(
|
||||
@PathVariable("keyName") String keyName);
|
||||
ResponseEntity<MgmtSystemTenantConfigurationValue> getTenantConfigurationValue(@PathVariable("keyName") String keyName);
|
||||
|
||||
/**
|
||||
* Handles the PUT request for updating a tenant specific configuration value.
|
||||
*
|
||||
* @param keyName the name of the configuration key
|
||||
* @param configurationValueRest the new value for the configuration
|
||||
* @return if the given configuration value exists and could be get HTTP OK. In any failure the JsonResponseExceptionHandler is handling the
|
||||
* response.
|
||||
*/
|
||||
@Operation(summary = "Update a tenant specific configuration value.", description = "The PUT request changes a " +
|
||||
"configuration value of a specific configuration key for the tenant. " +
|
||||
@@ -181,7 +146,8 @@ public interface MgmtTenantManagementRestApi {
|
||||
@PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<MgmtSystemTenantConfigurationValue> updateTenantConfigurationValue(
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
void updateTenantConfigurationValue(
|
||||
@PathVariable("keyName") String keyName,
|
||||
@RequestBody MgmtSystemTenantConfigurationValueRequest configurationValueRest);
|
||||
|
||||
@@ -189,8 +155,6 @@ public interface MgmtTenantManagementRestApi {
|
||||
* Handles the PUT request for updating a batch of tenant specific configurations
|
||||
*
|
||||
* @param configurationValueMap a Map of name - value pairs for the configurations
|
||||
* @return if the given configurations values exists and could be get HTTP OK. In any failure the JsonResponseExceptionHandler is handling
|
||||
* the response.
|
||||
*/
|
||||
@Operation(summary = "Batch update of tenant configuration.", description = "The PUT request updates the whole " +
|
||||
"configuration for the tenant. Required Permission: TENANT_CONFIGURATION")
|
||||
@@ -221,6 +185,39 @@ public interface MgmtTenantManagementRestApi {
|
||||
@PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs",
|
||||
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<List<MgmtSystemTenantConfigurationValue>> updateTenantConfiguration(
|
||||
@RequestBody Map<String, Serializable> configurationValueMap);
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
void updateTenantConfiguration(@RequestBody Map<String, Object> configurationValueMap);
|
||||
|
||||
/**
|
||||
* Handles the DELETE request of deleting a tenant specific configuration value.
|
||||
*
|
||||
* @param keyName the Name of the configuration key
|
||||
*/
|
||||
@Operation(summary = "Delete a tenant specific configuration value", description = "The DELETE request removes a " +
|
||||
"tenant specific configuration value for the tenant. Afterwards the global default value is used. " +
|
||||
"Required Permission: TENANT_CONFIGURATION")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "204", description = "Successfully deleted"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
|
||||
@ApiResponse(responseCode = "401", description = "The request requires user auth.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "403",
|
||||
description = "Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or " +
|
||||
"data volume restriction applies.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "404", description = "The key to remove is not found.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
|
||||
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
|
||||
"and the client has to wait another second.",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
||||
})
|
||||
@DeleteMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
void deleteTenantConfigurationValue(@PathVariable("keyName") String keyName);
|
||||
}
|
||||
Reference in New Issue
Block a user