Rename and split rest resources ddi, mgmt and system

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-20 17:33:03 +02:00
parent 8a22ea3df3
commit c3c405c986
169 changed files with 3081 additions and 1871 deletions

View File

@@ -0,0 +1,33 @@
<!--
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-parent</artifactId>
<version>0.2.0-SNAPSHOT</version>
</parent>
<artifactId>hawkbit-system-api</artifactId>
<name>hawkBit :: System REST API</name>
<dependencies>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.json.model.system;
import org.springframework.hateoas.ResourceSupport;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* A json annotated rest model for a tenant configuration value to RESTful API
* representation.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantConfigurationValue extends ResourceSupport {
@JsonInclude(Include.ALWAYS)
private Object value;
@JsonInclude(Include.ALWAYS)
private boolean isGlobal = true;
private Long lastModifiedAt;
private String lastModifiedBy;
private Long createdAt;
private String createdBy;
public Object getValue() {
return value;
}
public void setValue(final Object value) {
this.value = value;
}
public boolean isGlobal() {
return isGlobal;
}
public void setGlobal(final boolean isGlobal) {
this.isGlobal = isGlobal;
}
public Long getLastModifiedAt() {
return lastModifiedAt;
}
public void setLastModifiedAt(final Long lastModifiedAt) {
this.lastModifiedAt = lastModifiedAt;
}
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(final String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public Long getCreatedAt() {
return createdAt;
}
public void setCreatedAt(final Long createdAt) {
this.createdAt = createdAt;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(final String createdBy) {
this.createdBy = createdBy;
}
}

View File

@@ -0,0 +1,43 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.json.model.system;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* A json annotated rest model for System Configuration for PUT.
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantConfigurationValueRequest {
@JsonProperty(required = true)
private Object value;
/**
*
* @return the value of the SystemTenantConfigurationValueRequest
*/
public Object getValue() {
return value;
}
/**
* Sets the SystemTenantConfigurationValueRequest
*
* @param value
*/
public void setValue(final Object value) {
this.value = value;
}
}

View File

@@ -0,0 +1,62 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.json.model.systemmanagement;
import java.util.Collection;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Model representation of an Cache entry as json.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SystemCache {
private final String name;
private final Collection<String> keys;
/**
* @param name
* the name of the cache
* @param cacheKeys
* the keys which contains in the cache
*/
public SystemCache(final String name, final Collection<String> cacheKeys) {
this.name = name;
this.keys = cacheKeys;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the keys
*/
public Collection<String> getKeys() {
return keys;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "SystemCache [name=" + name + ", keys=" + keys + "]";
}
}

View File

@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.json.model.systemmanagement;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Body for system statistics.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SystemStatisticsRest {
private long overallTargets;
private long overallArtifacts;
private long overallArtifactVolumeInBytes;
private long overallActions;
private long overallTenants;
private List<SystemTenantServiceUsage> tenantStats;
public long getOverallTargets() {
return overallTargets;
}
public SystemStatisticsRest setOverallTargets(final long overallTargets) {
this.overallTargets = overallTargets;
return this;
}
public long getOverallArtifacts() {
return overallArtifacts;
}
public SystemStatisticsRest setOverallArtifacts(final long overallArtifacts) {
this.overallArtifacts = overallArtifacts;
return this;
}
public long getOverallArtifactVolumeInBytes() {
return overallArtifactVolumeInBytes;
}
public SystemStatisticsRest setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) {
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
return this;
}
public long getOverallActions() {
return overallActions;
}
public SystemStatisticsRest setOverallActions(final long overallActions) {
this.overallActions = overallActions;
return this;
}
public long getOverallTenants() {
return overallTenants;
}
public SystemStatisticsRest setOverallTenants(final long overallTenants) {
this.overallTenants = overallTenants;
return this;
}
public void setTenantStats(final List<SystemTenantServiceUsage> tenantStats) {
this.tenantStats = tenantStats;
}
public List<SystemTenantServiceUsage> getTenantStats() {
return tenantStats;
}
}

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.json.model.systemmanagement;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Response body for system usage report.
*
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SystemTenantServiceUsage {
private final String tenantName;
private long targets;
private long artifacts;
private long actions;
private long overallArtifactVolumeInBytes;
/**
* Constructor.
*
* @param tenantName
*/
public SystemTenantServiceUsage(final String tenantName) {
super();
this.tenantName = tenantName;
}
public long getTargets() {
return targets;
}
public void setTargets(final long targets) {
this.targets = targets;
}
public long getArtifacts() {
return artifacts;
}
public void setArtifacts(final long artifacts) {
this.artifacts = artifacts;
}
public long getActions() {
return actions;
}
public void setActions(final long actions) {
this.actions = actions;
}
public long getOverallArtifactVolumeInBytes() {
return overallArtifactVolumeInBytes;
}
public void setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) {
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
}
public String getTenantName() {
return tenantName;
}
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.api;
import java.util.Collection;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemCache;
import org.eclipse.hawkbit.system.json.model.systemmanagement.SystemStatisticsRest;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* {@link SystemManagement} capabilities by REST.
*
*/
@RequestMapping(SystemRestConstant.SYSTEM_ADMIN_MAPPING)
public interface SystemManagementRestApi {
/**
* Deletes the tenant data of a given tenant. USE WITH CARE!
*
* @param tenant
* to delete
* @return HttpStatus.OK
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/tenants/{tenant}")
ResponseEntity<Void> deleteTenant(@PathVariable final String tenant);
/**
* Collects and returns system usage statistics. It provides a system wide
* overview and tenant based stats.
*
* @return system usage statistics
*/
@RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<SystemStatisticsRest> getSystemUsageStats();
/**
* Returns a list of all caches.
*
* @return a list of caches for all tenants
*/
@RequestMapping(method = RequestMethod.GET, value = "/caches")
ResponseEntity<Collection<SystemCache>> getCaches();
/**
* Invalidates all caches for all tenants.
*
* @return a list of cache names which has been invalidated
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/caches")
ResponseEntity<Collection<String>> invalidateCaches();
}

View File

@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.api;
import java.util.Map;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValue;
import org.eclipse.hawkbit.system.json.model.system.SystemTenantConfigurationValueRequest;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* REST Resource handling tenant specific configuration operations.
*
*
*/
@RequestMapping(SystemRestConstant.SYSTEM_V1_REQUEST_MAPPING)
public interface SystemRestApi {
@RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<ResourceSupport> getSystem();
/**
* @return a Map of all configuration values.
*/
@RequestMapping(method = RequestMethod.GET, value = "/configs", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Map<String, SystemTenantConfigurationValue>> getSystemConfiguration();
/**
* 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.
*/
@RequestMapping(method = RequestMethod.DELETE, value = "/configs/{keyName}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> deleteConfigurationValue(@PathVariable final String keyName);
/**
* 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.
*/
@RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<SystemTenantConfigurationValue> getConfigurationValue(@PathVariable final String 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.
*/
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<SystemTenantConfigurationValue> updateConfigurationValue(@PathVariable final String keyName,
@RequestBody final SystemTenantConfigurationValueRequest configurationValueRest);
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.system.rest.api;
/**
*
*/
public final class SystemRestConstant {
/**
* API version definition. We are using only major versions.
*/
public static final String API_VERSION = "v1";
/**
* The base URL mapping for the spring acuator management context path.
*/
public static final String BASE_SYSTEM_MAPPING = "/system";
/**
* The base URL mapping of the SP rest resources.
*/
public static final String BASE_V1_REQUEST_MAPPING = "/rest/" + API_VERSION;
/**
* URL mapping for system admin operations.
*/
public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin";
public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + BASE_SYSTEM_MAPPING;
private SystemRestConstant() {
}
}