REST: add runtime info to root resource response ()

This adds basic information about the runtime in the response
to the root `/rest` API resource, mostly for display purposes
by UIs: the version, build string and the location of the
configuration and user data folders.

Signed-off-by: Yannick Schaus <github@schaus.net>
pull/1575/head
Yannick Schaus 2020-07-25 18:18:07 +02:00 committed by GitHub
parent aac4ca2f79
commit 0d635ce970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions
bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources

View File

@ -82,7 +82,7 @@ public class RootResource {
}
@GET
@ApiOperation(value = "Gets the API version and links to resources.")
@ApiOperation(value = "Gets information about the runtime, the API version and links to resources.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK") })
public Object getRoot(@Context UriInfo uriInfo) {
// key: path, value: name (this way we could ensure that ever path is added only once).

View File

@ -15,6 +15,7 @@ package org.openhab.core.io.rest.internal.resources.beans;
import java.util.ArrayList;
import java.util.List;
import org.openhab.core.OpenHAB;
import org.openhab.core.io.rest.RESTConstants;
/**
@ -22,13 +23,23 @@ import org.openhab.core.io.rest.RESTConstants;
* page of the REST interface.
*
* @author Kai Kreuzer - Initial contribution
* @author Yannick Schaus - Add runtime info
*/
public class RootBean {
public final String version = RESTConstants.API_VERSION;
public final RuntimeInfo runtimeInfo = new RuntimeInfo();
public final List<Links> links = new ArrayList<>();
public static class RuntimeInfo {
public final String version = OpenHAB.getVersion();
public final String buildString = OpenHAB.buildString();
public final String configFolder = OpenHAB.getConfigFolder();
public final String userdataFolder = OpenHAB.getUserDataFolder();
}
public static class Links {
public Links(String type, String url) {
this.type = type;