diff --git a/docs/src/main/resources/documentation/interfaces/management-api.md b/docs/src/main/resources/documentation/interfaces/management-api.md index e314599fa..6b5019a00 100644 --- a/docs/src/main/resources/documentation/interfaces/management-api.md +++ b/docs/src/main/resources/documentation/interfaces/management-api.md @@ -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 diff --git a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSystemClientResource.java b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtTenantManagementClientResource.java similarity index 58% rename from examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSystemClientResource.java rename to examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtTenantManagementClientResource.java index 9486bc560..748eac617 100644 --- a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSystemClientResource.java +++ b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtTenantManagementClientResource.java @@ -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 { } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java similarity index 63% rename from hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java rename to hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java index 23f337ceb..1be236fe3 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java @@ -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 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> getSystemConfiguration(); + ResponseEntity> 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 deleteConfigurationValue(@PathVariable("keyName") String keyName); + ResponseEntity 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 getConfigurationValue(@PathVariable("keyName") String keyName); + ResponseEntity 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 updateConfigurationValue(@PathVariable("keyName") String keyName, - MgmtSystemTenantConfigurationValueRequest configurationValueRest); + ResponseEntity updateTenantConfigurationValue( + @PathVariable("keyName") String keyName, MgmtSystemTenantConfigurationValueRequest configurationValueRest); } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java similarity index 90% rename from hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java index caa34734a..034a68758 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java @@ -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; } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java similarity index 50% rename from hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java rename to hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java index 0a846462e..a485a666c 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java @@ -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 getSystem() { - final ResourceSupport resourceSupport = new ResourceSupport(); - resourceSupport.add(linkTo(methodOn(MgmtSystemResource.class).getSystemConfiguration()).withRel("configs")); - return ResponseEntity.ok(resourceSupport); + public ResponseEntity> getTenantConfiguration() { + return ResponseEntity.ok( + MgmtTenantManagementMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties)); } - /** - * @return a Map of all configuration values. - */ @Override - public ResponseEntity> 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 deleteConfigurationValue(@PathVariable("keyName") final String keyName) { + public ResponseEntity 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 getConfigurationValue( + public ResponseEntity 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 updateConfigurationValue( + public ResponseEntity updateTenantConfigurationValue( @PathVariable("keyName") final String keyName, @RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest) { final TenantConfigurationValue updatedValue = tenantConfigurationManagement .addOrUpdateConfiguration(keyName, configurationValueRest.getValue()); - return ResponseEntity.ok(MgmtSystemMapper.toResponse(keyName, updatedValue)); + return ResponseEntity.ok(MgmtTenantManagementMapper.toResponse(keyName, updatedValue)); } }