ONOS-2486 Adding swagger-based REST API documentation.
Change-Id: I237d973d73549ad30ddc638c1c201f024d344c70
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ComponentConfigWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/ComponentConfigWebResource.java
index 1155be2..4adb6c5 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ComponentConfigWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ComponentConfigWebResource.java
@@ -33,11 +33,17 @@
import static org.onlab.util.Tools.nullIsNotFound;
/**
- * REST resource for cluster-wide component configuration.
+ * Manage component configurations.
*/
@Path("configuration")
public class ComponentConfigWebResource extends AbstractWebResource {
+ /**
+ * Get all component configurations.
+ * Returns collection of all registered component configurations.
+ *
+ * @return 200 OK
+ */
@GET
public Response getComponentConfigs() {
ComponentConfigService service = get(ComponentConfigService.class);
@@ -47,6 +53,12 @@
return ok(root).build();
}
+ /**
+ * Get configuration of the specified component.
+ *
+ * @param component component name
+ * @return 200 OK
+ */
@GET
@Path("{component}")
public Response getComponentConfigs(@PathParam("component") String component) {
@@ -65,10 +77,17 @@
props.forEach(p -> compNode.put(p.name(), p.value()));
}
+ /**
+ * Selectively set configuration properties.
+ * Sets only the properties present in the JSON request.
+ *
+ * @param component component name
+ * @return 200 OK
+ */
@POST
@Path("{component}")
- public Response setComponentConfigs(@PathParam("component") String component,
- InputStream request) throws IOException {
+ public Response setConfigs(@PathParam("component") String component,
+ InputStream request) throws IOException {
ComponentConfigService service = get(ComponentConfigService.class);
ObjectNode props = (ObjectNode) mapper().readTree(request);
props.fieldNames().forEachRemaining(k -> service.setProperty(component, k,
@@ -76,10 +95,17 @@
return Response.noContent().build();
}
+ /**
+ * Selectively clear configuration properties.
+ * Clears only the properties present in the JSON request.
+ *
+ * @param component component name
+ * @return 200 OK
+ */
@DELETE
@Path("{component}")
- public Response unsetComponentConfigs(@PathParam("component") String component,
- InputStream request) throws IOException {
+ public Response unsetConfigs(@PathParam("component") String component,
+ InputStream request) throws IOException {
ComponentConfigService service = get(ComponentConfigService.class);
ObjectNode props = (ObjectNode) mapper().readTree(request);
props.fieldNames().forEachRemaining(k -> service.unsetProperty(component, k));