Fix document tenant configuration api (#567)

* Added link to system docu
* Rename feign client to MgmtTenantManagementClient

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Knoblauch
2017-08-15 08:17:56 +02:00
committed by Michael Hirsch
parent 4fab134168
commit 4f79b8ba47
5 changed files with 45 additions and 91 deletions

View File

@@ -37,6 +37,7 @@ Available Management APIs resources are:
* [Target Tag](https://docs.bosch-iot-rollouts.com/documentation/rest-api/targettag-api-guide.html)
* [Distribution Set Tag](https://docs.bosch-iot-rollouts.com/documentation/rest-api/distributionsettag-api-guide.html)
* [Rollouts](https://docs.bosch-iot-rollouts.com/documentation/rest-api/rollout-api-guide.html)
* [Tenant](https://docs.bosch-iot-rollouts.com/documentation/rest-api/tenant-api-guide.html)
## Headers

View File

@@ -8,13 +8,13 @@
*/
package org.eclipse.hawkbit.mgmt.client.resource;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi;
import org.springframework.cloud.netflix.feign.FeignClient;
/**
* Client binding for the {@link MgmtSystemRestApi}.
* Client binding for the {@link MgmtTenantManagementRestApi}.
*
*/
@FeignClient(name = "MgmtSystemClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtSystemClientResource extends MgmtSystemRestApi {
@FeignClient(name = "MgmtTenantManagementClient", url = "${hawkbit.url:localhost:8080}")
public interface MgmtTenantManagementClientResource extends MgmtTenantManagementRestApi {
}

View File

@@ -13,7 +13,6 @@ import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -21,68 +20,67 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* REST Resource handling tenant specific configuration operations.
*
* REST Resource for handling tenant specific configuration operations.
*
*/
@RequestMapping(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING)
public interface MgmtSystemRestApi {
@RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<ResourceSupport> getSystem();
public interface MgmtTenantManagementRestApi {
/**
* @return a Map of all configuration values.
* Handles the GET request for receiving all tenant specific configuration
* values.
*
* @return a map of all configuration values.
*/
@RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getSystemConfiguration();
ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getTenantConfiguration();
/**
* Handles the DELETE request of deleting a tenant specific configuration
* value within SP.
* value.
*
* @param keyName
* the Name of the configuration key
* @return If the given configuration value exists and could be deleted Http
* @return if the given configuration value exists and could be deleted HTTP
* OK. In any failure the JsonResponseExceptionHandler is handling
* the response.
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/configs/{keyName}", produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> deleteConfigurationValue(@PathVariable("keyName") String keyName);
ResponseEntity<Void> deleteTenantConfigurationValue(@PathVariable("keyName") String keyName);
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
* Handles the GET request of receiving a tenant specific configuration
* value.
*
* @param keyName
* the Name of the configuration key
* @return If the given configuration value exists and could be get Http OK.
* the name of the configuration key
* @return if the given configuration value exists and could be get HTTP OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSystemTenantConfigurationValue> getConfigurationValue(@PathVariable("keyName") String keyName);
ResponseEntity<MgmtSystemTenantConfigurationValue> getTenantConfigurationValue(
@PathVariable("keyName") String keyName);
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
* Handles the PUT request for updating a tenant specific configuration
* value.
*
* @param keyName
* the Name of the configuration key
* 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.
* @return if the given configuration value exists and could be get HTTP OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(@PathVariable("keyName") String keyName,
MgmtSystemTenantConfigurationValueRequest configurationValueRest);
ResponseEntity<MgmtSystemTenantConfigurationValue> updateTenantConfigurationValue(
@PathVariable("keyName") String keyName, MgmtSystemTenantConfigurationValueRequest configurationValueRest);
}

View File

@@ -24,9 +24,9 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
* A mapper which maps repository model to RESTful model representation and
* back.
*/
public final class MgmtSystemMapper {
public final class MgmtTenantManagementMapper {
private MgmtSystemMapper() {
private MgmtTenantManagementMapper() {
// Utility class
}
@@ -50,7 +50,8 @@ public final class MgmtSystemMapper {
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy());
restConfValue.add(linkTo(methodOn(MgmtSystemResource.class).getConfigurationValue(key)).withSelfRel());
restConfValue.add(
linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)).withSelfRel());
return restConfValue;
}

View File

@@ -8,22 +8,18 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.io.Serializable;
import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -31,51 +27,31 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* REST Resource handling tenant specific configuration operations.
* REST Resource for handling tenant specific configuration operations.
*/
@RestController
public class MgmtSystemResource implements MgmtSystemRestApi {
public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtSystemResource.class);
private static final Logger LOG = LoggerFactory.getLogger(MgmtTenantManagementResource.class);
private final TenantConfigurationManagement tenantConfigurationManagement;
private final TenantConfigurationProperties tenantConfigurationProperties;
@Autowired
MgmtSystemResource(final TenantConfigurationManagement tenantConfigurationManagement,
MgmtTenantManagementResource(final TenantConfigurationManagement tenantConfigurationManagement,
final TenantConfigurationProperties tenantConfigurationProperties) {
this.tenantConfigurationManagement = tenantConfigurationManagement;
this.tenantConfigurationProperties = tenantConfigurationProperties;
}
@Override
public ResponseEntity<ResourceSupport> getSystem() {
final ResourceSupport resourceSupport = new ResourceSupport();
resourceSupport.add(linkTo(methodOn(MgmtSystemResource.class).getSystemConfiguration()).withRel("configs"));
return ResponseEntity.ok(resourceSupport);
public ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getTenantConfiguration() {
return ResponseEntity.ok(
MgmtTenantManagementMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties));
}
/**
* @return a Map of all configuration values.
*/
@Override
public ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getSystemConfiguration() {
return ResponseEntity
.ok(MgmtSystemMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties));
}
/**
* Handles the DELETE request of deleting a tenant specific configuration
* value within SP.
*
* @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.
*/
@Override
public ResponseEntity<Void> deleteConfigurationValue(@PathVariable("keyName") final String keyName) {
public ResponseEntity<Void> deleteTenantConfigurationValue(@PathVariable("keyName") final String keyName) {
tenantConfigurationManagement.deleteConfiguration(keyName);
@@ -83,45 +59,23 @@ public class MgmtSystemResource implements MgmtSystemRestApi {
return ResponseEntity.ok().build();
}
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
*
* @param keyName
* the Name of the configuration key
* @return If the given configuration value exists and could be get Http OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@Override
public ResponseEntity<MgmtSystemTenantConfigurationValue> getConfigurationValue(
public ResponseEntity<MgmtSystemTenantConfigurationValue> getTenantConfigurationValue(
@PathVariable("keyName") final String keyName) {
LOG.debug("{} config value getted, return status {}", keyName, HttpStatus.OK);
return ResponseEntity
.ok(MgmtSystemMapper.toResponse(keyName, tenantConfigurationManagement.getConfigurationValue(keyName)));
return ResponseEntity.ok(MgmtTenantManagementMapper.toResponse(keyName,
tenantConfigurationManagement.getConfigurationValue(keyName)));
}
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
*
* @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.
*/
@Override
public ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(
public ResponseEntity<MgmtSystemTenantConfigurationValue> updateTenantConfigurationValue(
@PathVariable("keyName") final String keyName,
@RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest) {
final TenantConfigurationValue<? extends Serializable> updatedValue = tenantConfigurationManagement
.addOrUpdateConfiguration(keyName, configurationValueRest.getValue());
return ResponseEntity.ok(MgmtSystemMapper.toResponse(keyName, updatedValue));
return ResponseEntity.ok(MgmtTenantManagementMapper.toResponse(keyName, updatedValue));
}
}