Fix indents in rest-api
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f7aa7627 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f7aa7627 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f7aa7627 Branch: refs/heads/master Commit: f7aa7627c982601302d241049b787f29872abff5 Parents: 7896657 Author: Aled Sage <[email protected]> Authored: Fri Jan 9 00:02:25 2015 +0000 Committer: Aled Sage <[email protected]> Committed: Wed Jan 14 19:30:10 2015 +0000 ---------------------------------------------------------------------- .../java/brooklyn/rest/api/ActivityApi.java | 54 ++- .../java/brooklyn/rest/api/ApplicationApi.java | 316 ++++++++------- .../main/java/brooklyn/rest/api/CatalogApi.java | 37 +- .../java/brooklyn/rest/api/EffectorApi.java | 89 ++--- .../main/java/brooklyn/rest/api/EntityApi.java | 392 +++++++++---------- .../java/brooklyn/rest/api/EntityConfigApi.java | 187 +++++---- .../java/brooklyn/rest/api/LocationApi.java | 66 ++-- .../main/java/brooklyn/rest/api/PolicyApi.java | 226 ++++++----- .../java/brooklyn/rest/api/PolicyConfigApi.java | 159 ++++---- .../main/java/brooklyn/rest/api/ScriptApi.java | 6 +- .../main/java/brooklyn/rest/api/SensorApi.java | 198 +++++----- .../main/java/brooklyn/rest/api/ServerApi.java | 37 +- .../main/java/brooklyn/rest/api/VersionApi.java | 6 +- .../brooklyn/rest/domain/ApplicationSpec.java | 243 ++++++------ .../brooklyn/rest/domain/ConfigSummary.java | 257 ++++++------ .../brooklyn/rest/domain/EffectorSummary.java | 252 ++++++------ .../rest/domain/EntityConfigSummary.java | 62 ++- .../java/brooklyn/rest/domain/EntitySpec.java | 135 ++++--- .../brooklyn/rest/domain/EntitySummary.java | 111 +++--- .../rest/domain/HighAvailabilitySummary.java | 134 ++++--- .../java/brooklyn/rest/domain/LocationSpec.java | 113 +++--- .../brooklyn/rest/domain/LocationSummary.java | 101 +++-- .../rest/domain/PolicyConfigSummary.java | 49 ++- .../brooklyn/rest/domain/PolicySummary.java | 152 ++++--- .../rest/domain/ScriptExecutionSummary.java | 13 +- .../brooklyn/rest/domain/SensorSummary.java | 146 ++++--- .../java/brooklyn/rest/domain/TaskSummary.java | 339 ++++++++-------- .../brooklyn/rest/domain/UsageStatistic.java | 12 +- .../brooklyn/rest/domain/UsageStatistics.java | 31 +- .../rest/domain/ApplicationSpecTest.java | 39 +- .../rest/domain/EffectorSummaryTest.java | 36 +- .../brooklyn/rest/domain/EntitySpecTest.java | 36 +- .../brooklyn/rest/domain/EntitySummaryTest.java | 48 +-- .../brooklyn/rest/domain/LocationSpecTest.java | 36 +- .../brooklyn/rest/util/RestApiTestUtils.java | 1 - 35 files changed, 2021 insertions(+), 2098 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/ActivityApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ActivityApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ActivityApi.java index 379187b..603b940 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/ActivityApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ActivityApi.java @@ -37,35 +37,33 @@ import javax.ws.rs.core.MediaType; @Consumes(MediaType.APPLICATION_JSON) public interface ActivityApi { - @GET - @Path("/{task}") - @ApiOperation(value = "Fetch task details", responseClass = "brooklyn.rest.domain.TaskSummary") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find task") - }) + @GET + @Path("/{task}") + @ApiOperation(value = "Fetch task details", responseClass = "brooklyn.rest.domain.TaskSummary") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find task") + }) // @Produces("text/json") - public TaskSummary get( - @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId - ); - - @GET - @Path("/{task}/children") - @ApiOperation(value = "Fetch list of children tasks of this task") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find task") - }) - public List<TaskSummary> children( - @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId); - - @GET - @Path("/{task}/stream/{streamId}") - @ApiOperation(value = "Return the contents of the given stream") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find task or stream") - }) - public String stream( - @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId, - @ApiParam(value = "Stream ID", required = true) @PathParam("streamId") String streamId); + public TaskSummary get( + @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId + ); + @GET + @Path("/{task}/children") + @ApiOperation(value = "Fetch list of children tasks of this task") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find task") + }) + public List<TaskSummary> children( + @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId); + @GET + @Path("/{task}/stream/{streamId}") + @ApiOperation(value = "Return the contents of the given stream") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find task or stream") + }) + public String stream( + @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId, + @ApiParam(value = "Stream ID", required = true) @PathParam("streamId") String streamId); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java index 6b67240..9292197 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java @@ -52,164 +52,162 @@ import com.wordnik.swagger.core.ApiParam; @Consumes(MediaType.APPLICATION_JSON) public interface ApplicationApi { - @GET - @Path("/tree") - @ApiOperation( - value = "Fetch applications and entities tree hierarchy" - ) - /** @deprecated since 0.6.0 use {@link #fetch(String)} (with slightly different, but better semantics) */ - @Deprecated - public JsonNode applicationTree(); - - @GET - @Path("/fetch") - @ApiOperation( - value = "Fetch display details for all applications and optionally selected additional entities" - ) - public JsonNode fetch( - @ApiParam(value="Selected additional entity ID's to include, comma-separated", required=false) - @DefaultValue("") - @QueryParam("items") String items); - - @GET - @ApiOperation( - value = "Fetch list of applications, as ApplicationSummary objects", - responseClass = "brooklyn.rest.domain.ApplicationSummary" - ) - public List<ApplicationSummary> list() ; - - @GET - @Path("/{application}") - @ApiOperation( - value = "Fetch a specific application", - responseClass = "brooklyn.rest.domain.ApplicationSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application not found") - }) - public ApplicationSummary get( - @ApiParam( - value = "ID or name of application whose details will be returned", - required = true) - @PathParam("application") String application) ; - - @POST - @Consumes({"application/x-yaml", - // see http://stackoverflow.com/questions/332129/yaml-mime-type - "text/yaml", "text/x-yaml", "application/yaml"}) - @ApiOperation( - value = "Create and start a new application from YAML", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined entity or location"), - @ApiError(code = 412, reason = "Application already registered") - }) - public Response createFromYaml( - @ApiParam( - name = "applicationSpec", - value = "App spec in CAMP YAML format", - required = true) - String yaml); - - // TODO archives -// @Consumes({"application/x-tar", "application/x-tgz", "application/x-zip"}) - - @POST - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN}) - @ApiOperation( - value = "Create and start a new application from miscellaneous types, including JSON either new CAMP format or legacy AppSpec format", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined entity or location"), - @ApiError(code = 412, reason = "Application already registered") - }) - public Response createPoly( - @ApiParam( - name = "applicationSpec", - value = "App spec in JSON, YAML, or other (auto-detected) format", - required = true) - byte[] autodetectedInput); - - @POST - @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) - @ApiOperation( - value = "Create and start a new application from form URL-encoded contents (underlying type autodetected)", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined entity or location"), - @ApiError(code = 412, reason = "Application already registered") - }) - public Response createFromForm( - @ApiParam( - name = "applicationSpec", - value = "App spec in form-encoded YAML, JSON, or other (auto-detected) format", - required = true) - @Valid String contents); - - @DELETE - @Path("/{application}") - @ApiOperation( - value = "Delete a specified application", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application not found") - }) - public Response delete( - @ApiParam( - name = "application", - value = "Application name", - required = true - ) - @PathParam("application") String application) ; - - /** @deprecated since 0.7.0 the {@link ApplicationSpec} is being retired in favour of CAMP YAML/ZIP - * (however in 0.7.0 you can still pass this object as JSON and it will be autodetected) */ - @POST - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN}) - @ApiOperation( - value = "Create and start a new application from miscellaneous types, including JSON either new CAMP format or legacy AppSpec format", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined entity or location"), - @ApiError(code = 412, reason = "Application already registered") - }) - @Path("/createLegacy") - @Deprecated - public Response create(ApplicationSpec applicationSpec); - - @GET - @Path("/{application}/descendants") - @ApiOperation(value = "Fetch entity info for all (or filtered) descendants", - responseClass = "brooklyn.rest.domain.EntitySummary") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public List<EntitySummary> getDescendants( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value="Regular expression for an entity type which must be matched", required=false) - @DefaultValue(".*") - @QueryParam("typeRegex") String typeRegex); - - @GET - @Path("/{application}/descendants/sensor/{sensor}") - @ApiOperation(value = "Fetch values of a given sensor for all (or filtered) descendants") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public Map<String,Object> getDescendantsSensor( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensor, - @ApiParam(value="Regular expression for an entity type which must be matched", required=false) - @DefaultValue(".*") - @QueryParam("typeRegex") String typeRegex - ); + @GET + @Path("/tree") + @ApiOperation( + value = "Fetch applications and entities tree hierarchy" + ) + /** @deprecated since 0.6.0 use {@link #fetch(String)} (with slightly different, but better semantics) */ + @Deprecated + public JsonNode applicationTree(); + + @GET + @Path("/fetch") + @ApiOperation( + value = "Fetch display details for all applications and optionally selected additional entities" + ) + public JsonNode fetch( + @ApiParam(value="Selected additional entity ID's to include, comma-separated", required=false) + @DefaultValue("") + @QueryParam("items") String items); + + @GET + @ApiOperation( + value = "Fetch list of applications, as ApplicationSummary objects", + responseClass = "brooklyn.rest.domain.ApplicationSummary" + ) + public List<ApplicationSummary> list(); + + @GET + @Path("/{application}") + @ApiOperation( + value = "Fetch a specific application", + responseClass = "brooklyn.rest.domain.ApplicationSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application not found") + }) + public ApplicationSummary get( + @ApiParam( + value = "ID or name of application whose details will be returned", + required = true) + @PathParam("application") String application); + + @POST + @Consumes({"application/x-yaml", + // see http://stackoverflow.com/questions/332129/yaml-mime-type + "text/yaml", "text/x-yaml", "application/yaml"}) + @ApiOperation( + value = "Create and start a new application from YAML", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined entity or location"), + @ApiError(code = 412, reason = "Application already registered") + }) + public Response createFromYaml( + @ApiParam( + name = "applicationSpec", + value = "App spec in CAMP YAML format", + required = true) + String yaml); + + // TODO archives +// @Consumes({"application/x-tar", "application/x-tgz", "application/x-zip"}) + + @POST + @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN}) + @ApiOperation( + value = "Create and start a new application from miscellaneous types, including JSON either new CAMP format or legacy AppSpec format", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined entity or location"), + @ApiError(code = 412, reason = "Application already registered") + }) + public Response createPoly( + @ApiParam( + name = "applicationSpec", + value = "App spec in JSON, YAML, or other (auto-detected) format", + required = true) + byte[] autodetectedInput); + + @POST + @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) + @ApiOperation( + value = "Create and start a new application from form URL-encoded contents (underlying type autodetected)", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined entity or location"), + @ApiError(code = 412, reason = "Application already registered") + }) + public Response createFromForm( + @ApiParam( + name = "applicationSpec", + value = "App spec in form-encoded YAML, JSON, or other (auto-detected) format", + required = true) + @Valid String contents); + + @DELETE + @Path("/{application}") + @ApiOperation( + value = "Delete a specified application", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application not found") + }) + public Response delete( + @ApiParam( + name = "application", + value = "Application name", + required = true) + @PathParam("application") String application); + + /** @deprecated since 0.7.0 the {@link ApplicationSpec} is being retired in favour of CAMP YAML/ZIP + * (however in 0.7.0 you can still pass this object as JSON and it will be autodetected) */ + @POST + @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN}) + @ApiOperation( + value = "Create and start a new application from miscellaneous types, including JSON either new CAMP format or legacy AppSpec format", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined entity or location"), + @ApiError(code = 412, reason = "Application already registered") + }) + @Path("/createLegacy") + @Deprecated + public Response create(ApplicationSpec applicationSpec); + + @GET + @Path("/{application}/descendants") + @ApiOperation(value = "Fetch entity info for all (or filtered) descendants", + responseClass = "brooklyn.rest.domain.EntitySummary") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public List<EntitySummary> getDescendants( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value="Regular expression for an entity type which must be matched", required=false) + @DefaultValue(".*") + @QueryParam("typeRegex") String typeRegex); + + @GET + @Path("/{application}/descendants/sensor/{sensor}") + @ApiOperation(value = "Fetch values of a given sensor for all (or filtered) descendants") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public Map<String,Object> getDescendantsSensor( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensor, + @ApiParam(value="Regular expression for an entity type which must be matched", required=false) + @DefaultValue(".*") + @QueryParam("typeRegex") String typeRegex); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java index f527d60..bbf9d2f 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java @@ -63,8 +63,7 @@ public interface CatalogApi { @ApiOperation(value = "Add a catalog item (e.g. new entity or policy type) by uploading YAML descriptor", responseClass = "String") public Response create( @ApiParam(name = "yaml", value = "YAML descriptor of catalog item", required = true) - @Valid String yaml - ) ; + @Valid String yaml); @POST @Consumes(MediaType.APPLICATION_XML) @@ -72,8 +71,7 @@ public interface CatalogApi { @ApiOperation(value = "Resets the catalog to the given (XML) format") public Response resetXml( @ApiParam(name = "xml", value = "XML descriptor of the entire catalog to install", required = true) - @Valid String xml - ) ; + @Valid String xml); /** @deprecated since 0.7.0 use {@link #getEntity(String, String)} */ @Deprecated @@ -85,7 +83,7 @@ public interface CatalogApi { }) public void deleteEntity( @ApiParam(name = "entityId", value = "The ID of the entity or template to delete", required = true) - @PathParam("entityId") String entityId) throws Exception ; + @PathParam("entityId") String entityId) throws Exception; @DELETE @Path("/entities/{entityId}/{version}") @@ -98,7 +96,7 @@ public interface CatalogApi { @PathParam("entityId") String entityId, @ApiParam(name = "version", value = "The version identifier of the entity or template to delete", required = true) - @PathParam("version") String version) throws Exception ; + @PathParam("version") String version) throws Exception; @GET @Path("/entities") @@ -107,8 +105,7 @@ public interface CatalogApi { @ApiParam(name = "regex", value = "Regular expression to search for") @QueryParam("regex") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") - @QueryParam("fragment") @DefaultValue("") String fragment - ) ; + @QueryParam("fragment") @DefaultValue("") String fragment); @GET @Path("/applications") @@ -117,8 +114,7 @@ public interface CatalogApi { @ApiParam(name = "regex", value = "Regular expression to search for") @QueryParam("regex") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") - @QueryParam("fragment") @DefaultValue("") String fragment - ) ; + @QueryParam("fragment") @DefaultValue("") String fragment); /** @deprecated since 0.7.0 use {@link #getEntity(String, String)} */ @Deprecated @@ -130,7 +126,7 @@ public interface CatalogApi { }) public CatalogEntitySummary getEntity( @ApiParam(name = "entityId", value = "The ID of the entity or template to retrieve", required = true) - @PathParam("entityId") String entityId) throws Exception ; + @PathParam("entityId") String entityId) throws Exception; @GET @Path("/entities/{entityId}/{version}") @@ -143,7 +139,7 @@ public interface CatalogApi { @PathParam("entityId") String entityId, @ApiParam(name = "version", value = "The version identifier of the entity or template to retrieve", required = true) - @PathParam("version") String version) throws Exception ; + @PathParam("version") String version) throws Exception; /** @deprecated since 0.7.0 use {@link #getEntity(String, String)} */ @Deprecated @@ -155,7 +151,7 @@ public interface CatalogApi { }) public CatalogEntitySummary getApplication( @ApiParam(name = "applicationId", value = "The ID of the application to retrieve", required = true) - @PathParam("applicationId") String entityId) throws Exception ; + @PathParam("applicationId") String entityId) throws Exception; @GET @Path("/applications/{applicationId}/{version}") @@ -168,7 +164,7 @@ public interface CatalogApi { @PathParam("applicationId") String entityId, @ApiParam(name = "version", value = "The version identifier of the application to retrieve", required = true) - @PathParam("version") String version) throws Exception ; + @PathParam("version") String version) throws Exception; @GET @Path("/policies") @@ -177,8 +173,7 @@ public interface CatalogApi { @ApiParam(name = "regex", value = "Regular expression to search for") @QueryParam("regex") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") - @QueryParam("fragment") @DefaultValue("") String fragment - ) ; + @QueryParam("fragment") @DefaultValue("") String fragment); /** @deprecated since 0.7.0 use {@link #getEntity(String, String)} */ @Deprecated @@ -190,7 +185,7 @@ public interface CatalogApi { }) public CatalogItemSummary getPolicy( @ApiParam(name = "policyId", value = "The ID of the policy to retrieve", required = true) - @PathParam("policyId") String policyId) throws Exception ; + @PathParam("policyId") String policyId) throws Exception; @GET @Path("/policies/{policyId}/{version}") @@ -202,7 +197,7 @@ public interface CatalogApi { @ApiParam(name = "policyId", value = "The ID of the policy to retrieve", required = true) @PathParam("policyId") String policyId, @ApiParam(name = "version", value = "The version identifier of the application to retrieve", required = true) - @PathParam("version") String version) throws Exception ; + @PathParam("version") String version) throws Exception; /** @deprecated since 0.7.0 use {@link #getIcon(String, String)} */ @Deprecated @@ -215,8 +210,7 @@ public interface CatalogApi { @Produces("application/image") public Response getIcon( @ApiParam(name = "itemId", value = "ID of catalog item (application, entity, policy)") - @PathParam("itemId") @DefaultValue("") String itemId - ) ; + @PathParam("itemId") @DefaultValue("") String itemId); @GET @Path("/icon/{itemId}/{version}") @@ -230,8 +224,7 @@ public interface CatalogApi { @PathParam("itemId") String itemId, @ApiParam(name = "version", value = "version identifier of catalog item (application, entity, policy)", required=true) - @PathParam("version") String version - ) ; + @PathParam("version") String version); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/EffectorApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/EffectorApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/EffectorApi.java index 59726fd..fe1f29e 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/EffectorApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/EffectorApi.java @@ -38,51 +38,48 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) public interface EffectorApi { - @GET - @ApiOperation(value = "Fetch the list of effectors", - responseClass = "brooklyn.rest.domain.EffectorSummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<EffectorSummary> list( - @ApiParam(name = "application", value = "Application name", required = true) - @PathParam("application") final String application, - @ApiParam(name = "entity", value = "Entity name", required = true) - @PathParam("entity") final String entityToken - ) ; - - @POST - @Path("/{effector}") - @ApiOperation(value = "Trigger an effector", - notes="Returns the return value (status 200) if it completes, or an activity task ID (status 202) if it times out") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or effector") - }) - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED}) - public Response invoke( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "effector", value = "Name of the effector to trigger", required = true) - @PathParam("effector") String effectorName, - - // TODO test timeout; and should it be header, form, or what? - @ApiParam(name = "timeout", value = "Delay before server should respond with activity task ID rather than result (in millis if no unit specified): " + - "'never' (blocking) is default; " + - "'0' means 'always' return task activity ID; " + - "and e.g. '1000' or '1s' will return a result if available within one second otherwise status 202 and the activity task ID", - required = false, defaultValue = "never") - @QueryParam("timeout") - String timeout, - - @ApiParam(/* FIXME: giving a `name` in swagger @ApiParam seems wrong as this object is the body, not a named argument */ name = "parameters", - value = "Effector parameters (as key value pairs)", required = false) - @Valid - Map<String, Object> parameters - ) ; + @GET + @ApiOperation(value = "Fetch the list of effectors", + responseClass = "brooklyn.rest.domain.EffectorSummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<EffectorSummary> list( + @ApiParam(name = "application", value = "Application name", required = true) + @PathParam("application") final String application, + @ApiParam(name = "entity", value = "Entity name", required = true) + @PathParam("entity") final String entityToken); + @POST + @Path("/{effector}") + @ApiOperation(value = "Trigger an effector", + notes="Returns the return value (status 200) if it completes, or an activity task ID (status 202) if it times out") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or effector") + }) + @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED}) + public Response invoke( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "effector", value = "Name of the effector to trigger", required = true) + @PathParam("effector") String effectorName, + + // TODO test timeout; and should it be header, form, or what? + @ApiParam(name = "timeout", value = "Delay before server should respond with activity task ID rather than result (in millis if no unit specified): " + + "'never' (blocking) is default; " + + "'0' means 'always' return task activity ID; " + + "and e.g. '1000' or '1s' will return a result if available within one second otherwise status 202 and the activity task ID", + required = false, defaultValue = "never") + @QueryParam("timeout") + String timeout, + + @ApiParam(/* FIXME: giving a `name` in swagger @ApiParam seems wrong as this object is the body, not a named argument */ name = "parameters", + value = "Effector parameters (as key value pairs)", required = false) + @Valid + Map<String, Object> parameters); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/EntityApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/EntityApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/EntityApi.java index f99ef18..feab918 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/EntityApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/EntityApi.java @@ -41,205 +41,195 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) public interface EntityApi { - @GET - @ApiOperation(value = "Fetch the list of entities for a given application", - responseClass = "brooklyn.rest.domain.EntitySummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application not found") - }) - public List<EntitySummary> list( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application) ; - - @GET - @Path("/{entity}") - @ApiOperation(value = "Fetch details about a specific application entity", - responseClass = "brooklyn.rest.domain.EntitySummary") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public EntitySummary get( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entity - ) ; - - // TODO rename as "/children" ? - @GET - @ApiOperation(value = "Fetch details about a specific application entity's children", - responseClass = "brooklyn.rest.domain.EntitySummary") - @Path("/{entity}/children") - public List<EntitySummary> getChildren( - @PathParam("application") final String application, - @PathParam("entity") final String entity - ); - - /** @deprecated since 0.7.0 use /children */ - @Deprecated - @Path("/{entity}/entities") - public List<EntitySummary> getChildrenOld( - @PathParam("application") final String application, - @PathParam("entity") final String entity - ); - - @POST - @ApiOperation(value = "Add a child or children to this entity given a YAML spec", - responseClass = "brooklyn.rest.domain.TaskSummary") - @Consumes({"application/x-yaml", - // see http://stackoverflow.com/questions/332129/yaml-mime-type - "text/yaml", "text/x-yaml", "application/yaml", MediaType.APPLICATION_JSON}) - @Path("/{entity}/children") - public Response addChildren( - @PathParam("application") final String application, - @PathParam("entity") final String entity, - - @ApiParam( - name = "start", - value = "Whether to automatically start this child; if omitted, true for Startable entities") - @QueryParam("start") final Boolean start, - - @ApiParam(name = "timeout", value = "Delay before server should respond with incomplete activity task, rather than completed task: " + - "'never' means block until complete; " + - "'0' means return task immediately; " + - "and e.g. '20ms' (the default) will wait 20ms for completed task information to be available", - required = false, defaultValue = "20ms") - @QueryParam("timeout") final String timeout, - - @ApiParam( - name = "childrenSpec", - value = "Entity spec in CAMP YAML format (including 'services' root element)", - required = true) - String yaml - ); - - @GET - @Path("/{entity}/activities") - @ApiOperation(value = "Fetch list of tasks for this entity") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<TaskSummary> listTasks( - @ApiParam(value = "Entity ID or name", required = true) @PathParam("application") String applicationId, - @ApiParam(value = "Application ID or name", required = true) @PathParam("entity") String entityId); - - @GET - @Path("/{entity}/activities/{task}") - @ApiOperation(value = "Fetch task details", responseClass = "brooklyn.rest.domain.TaskSummary") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or task") - }) - @Produces("text/json") - public TaskSummary getTask( - @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityToken, - @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId - ); - - @GET - @ApiOperation(value = "Returns an icon for the entity, if defined") - @Path("/{entity}/icon") - public Response getIcon( - @PathParam("application") final String application, - @PathParam("entity") final String entity - ); - - @GET - @Path("/{entity}/tags") - @ApiOperation(value = "Fetch list of tags on this entity") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<Object> listTags( - @ApiParam(value = "Entity ID or name", required = true) @PathParam("application") String applicationId, - @ApiParam(value = "Application ID or name", required = true) @PathParam("entity") String entityId); - - @POST - @ApiOperation( - value = "Rename an entity" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined application or entity") - }) - @Path("/{entity}/name") - public Response rename( - @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String applicationId, - @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityId, - @ApiParam(value = "New name for this entity", required = true) @QueryParam("name") final String name); - - @POST - @ApiOperation( - value = "Expunge an entity", - responseClass = "brooklyn.rest.domain.TaskSummary" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Undefined application or entity") - }) - @Path("/{entity}/expunge") - public Response expunge( - @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String applicationId, - @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityId, - @ApiParam(value = "Whether to gracefully release all resources", required = true) @QueryParam("release") final boolean release); - - @GET - @Path("/{entity}/descendants") - @ApiOperation(value = "Fetch entity info for all (or filtered) descendants", - responseClass = "brooklyn.rest.domain.EntitySummary") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public List<EntitySummary> getDescendants( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entity, - @ApiParam(value="Regular expression for an entity type which must be matched", required=false) - @DefaultValue(".*") - @QueryParam("typeRegex") String typeRegex - ); - - @GET - @Path("/{entity}/descendants/sensor/{sensor}") - @ApiOperation(value = "Fetch values of a given sensor for all (or filtered) descendants") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public Map<String,Object> getDescendantsSensor( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entity, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensor, - @ApiParam(value="Regular expression applied to filter descendant entities based on their type", required=false) - @DefaultValue(".*") - @QueryParam("typeRegex") String typeRegex - ); - - @GET - @Path("/{entity}/locations") - @ApiOperation(value = "List the locations set on the entity") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public List<LocationSummary> getLocations( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entity); - - @GET - @Path("/{entity}/spec") - @ApiOperation(value = "Get the YAML spec used to create the entity, if available") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application or entity missing") - }) - public String getSpec( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entity - ) ; - + @GET + @ApiOperation(value = "Fetch the list of entities for a given application", + responseClass = "brooklyn.rest.domain.EntitySummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application not found") + }) + public List<EntitySummary> list( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application) ; + + @GET + @Path("/{entity}") + @ApiOperation(value = "Fetch details about a specific application entity", + responseClass = "brooklyn.rest.domain.EntitySummary") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public EntitySummary get( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entity); + + // TODO rename as "/children" ? + @GET + @ApiOperation(value = "Fetch details about a specific application entity's children", + responseClass = "brooklyn.rest.domain.EntitySummary") + @Path("/{entity}/children") + public List<EntitySummary> getChildren( + @PathParam("application") final String application, + @PathParam("entity") final String entity); + + /** @deprecated since 0.7.0 use /children */ + @Deprecated + @Path("/{entity}/entities") + public List<EntitySummary> getChildrenOld( + @PathParam("application") final String application, + @PathParam("entity") final String entity); + + @POST + @ApiOperation(value = "Add a child or children to this entity given a YAML spec", + responseClass = "brooklyn.rest.domain.TaskSummary") + @Consumes({"application/x-yaml", + // see http://stackoverflow.com/questions/332129/yaml-mime-type + "text/yaml", "text/x-yaml", "application/yaml", MediaType.APPLICATION_JSON}) + @Path("/{entity}/children") + public Response addChildren( + @PathParam("application") final String application, + @PathParam("entity") final String entity, + + @ApiParam( + name = "start", + value = "Whether to automatically start this child; if omitted, true for Startable entities") + @QueryParam("start") final Boolean start, + + @ApiParam(name = "timeout", value = "Delay before server should respond with incomplete activity task, rather than completed task: " + + "'never' means block until complete; " + + "'0' means return task immediately; " + + "and e.g. '20ms' (the default) will wait 20ms for completed task information to be available", + required = false, defaultValue = "20ms") + @QueryParam("timeout") final String timeout, + + @ApiParam( + name = "childrenSpec", + value = "Entity spec in CAMP YAML format (including 'services' root element)", + required = true) + String yaml); + + @GET + @Path("/{entity}/activities") + @ApiOperation(value = "Fetch list of tasks for this entity") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<TaskSummary> listTasks( + @ApiParam(value = "Entity ID or name", required = true) @PathParam("application") String applicationId, + @ApiParam(value = "Application ID or name", required = true) @PathParam("entity") String entityId); + + @GET + @Path("/{entity}/activities/{task}") + @ApiOperation(value = "Fetch task details", responseClass = "brooklyn.rest.domain.TaskSummary") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or task") + }) + @Produces("text/json") + public TaskSummary getTask( + @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityToken, + @ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId); + + @GET + @ApiOperation(value = "Returns an icon for the entity, if defined") + @Path("/{entity}/icon") + public Response getIcon( + @PathParam("application") final String application, + @PathParam("entity") final String entity); + + @GET + @Path("/{entity}/tags") + @ApiOperation(value = "Fetch list of tags on this entity") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<Object> listTags( + @ApiParam(value = "Entity ID or name", required = true) @PathParam("application") String applicationId, + @ApiParam(value = "Application ID or name", required = true) @PathParam("entity") String entityId); + + @POST + @ApiOperation( + value = "Rename an entity" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined application or entity") + }) + @Path("/{entity}/name") + public Response rename( + @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String applicationId, + @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityId, + @ApiParam(value = "New name for this entity", required = true) @QueryParam("name") final String name); + + @POST + @ApiOperation( + value = "Expunge an entity", + responseClass = "brooklyn.rest.domain.TaskSummary" + ) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Undefined application or entity") + }) + @Path("/{entity}/expunge") + public Response expunge( + @ApiParam(value = "Application ID or name", required = true) @PathParam("application") final String applicationId, + @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") final String entityId, + @ApiParam(value = "Whether to gracefully release all resources", required = true) @QueryParam("release") final boolean release); + + @GET + @Path("/{entity}/descendants") + @ApiOperation(value = "Fetch entity info for all (or filtered) descendants", + responseClass = "brooklyn.rest.domain.EntitySummary") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public List<EntitySummary> getDescendants( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entity, + @ApiParam(value="Regular expression for an entity type which must be matched", required=false) + @DefaultValue(".*") + @QueryParam("typeRegex") String typeRegex); + + @GET + @Path("/{entity}/descendants/sensor/{sensor}") + @ApiOperation(value = "Fetch values of a given sensor for all (or filtered) descendants") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public Map<String,Object> getDescendantsSensor( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entity, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensor, + @ApiParam(value="Regular expression applied to filter descendant entities based on their type", required=false) + @DefaultValue(".*") + @QueryParam("typeRegex") String typeRegex); + + @GET + @Path("/{entity}/locations") + @ApiOperation(value = "List the locations set on the entity") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public List<LocationSummary> getLocations( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entity); + + @GET + @Path("/{entity}/spec") + @ApiOperation(value = "Get the YAML spec used to create the entity, if available") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Application or entity missing") + }) + public String getSpec( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entity); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/EntityConfigApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/EntityConfigApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/EntityConfigApi.java index 75f39b3..b8b75b4 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/EntityConfigApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/EntityConfigApi.java @@ -38,107 +38,100 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) public interface EntityConfigApi { - @GET - @ApiOperation(value = "Fetch the config keys for a specific application entity", - responseClass = "brooklyn.rest.domain.ConfigSummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<EntityConfigSummary> list( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken - ) ; + @GET + @ApiOperation(value = "Fetch the config keys for a specific application entity", + responseClass = "brooklyn.rest.domain.ConfigSummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<EntityConfigSummary> list( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken); - // TODO support parameters ?show=value,summary&name=xxx &format={string,json,xml} - // (and in sensors class) - @GET - @Path("/current-state") - @ApiOperation(value = "Fetch config key values in batch", notes="Returns a map of config name to value") - public Map<String, Object> batchConfigRead( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Return raw config data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ) ; - - @GET - @Path("/{config}") - @ApiOperation(value = "Fetch config value (json)", responseClass = "Object") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or config key") - }) - @Produces(MediaType.APPLICATION_JSON) - public Object get( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Config key ID", required = true) - @PathParam("config") String configKeyName, - @ApiParam(value = "Return raw config data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ); + // TODO support parameters ?show=value,summary&name=xxx &format={string,json,xml} + // (and in sensors class) + @GET + @Path("/current-state") + @ApiOperation(value = "Fetch config key values in batch", notes="Returns a map of config name to value") + public Map<String, Object> batchConfigRead( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Return raw config data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - // if user requests plain value we skip some json post-processing - @GET - @Path("/{config}") - @ApiOperation(value = "Fetch config value (text/plain)", responseClass = "Object") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or config key") - }) - @Produces(MediaType.TEXT_PLAIN) - public String getPlain( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Config key ID", required = true) - @PathParam("config") String configKeyName, - @ApiParam(value = "Return raw config data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ); + @GET + @Path("/{config}") + @ApiOperation(value = "Fetch config value (json)", responseClass = "Object") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or config key") + }) + @Produces(MediaType.APPLICATION_JSON) + public Object get( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Config key ID", required = true) + @PathParam("config") String configKeyName, + @ApiParam(value = "Return raw config data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - @POST - @ApiOperation(value = "Manually set multiple config values") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - @SuppressWarnings("rawtypes") - public void setFromMap( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Apply the config to all pre-existing descendants", required = false) - @QueryParam("recurse") @DefaultValue("false") final Boolean recurse, - @ApiParam(value = "Map of config key names to values", required = true) - Map newValues - ) ; + // if user requests plain value we skip some json post-processing + @GET + @Path("/{config}") + @ApiOperation(value = "Fetch config value (text/plain)", responseClass = "Object") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or config key") + }) + @Produces(MediaType.TEXT_PLAIN) + public String getPlain( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Config key ID", required = true) + @PathParam("config") String configKeyName, + @ApiParam(value = "Return raw config data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - @POST - @Path("/{config}") - @ApiOperation(value = "Manually set a config value") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or config key") - }) - public void set( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Config key name", required = true) - @PathParam("config") String configName, - @ApiParam(value = "Apply the config to all pre-existing descendants", required = false) - @QueryParam("recurse") @DefaultValue("false") final Boolean recurse, - @ApiParam(value = "Value to set") - Object newValue - ) ; + @POST + @ApiOperation(value = "Manually set multiple config values") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + @SuppressWarnings("rawtypes") + public void setFromMap( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Apply the config to all pre-existing descendants", required = false) + @QueryParam("recurse") @DefaultValue("false") final Boolean recurse, + @ApiParam(value = "Map of config key names to values", required = true) + Map newValues); - // deletion of config is not supported; you can set it null + @POST + @Path("/{config}") + @ApiOperation(value = "Manually set a config value") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or config key") + }) + public void set( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Config key name", required = true) + @PathParam("config") String configName, + @ApiParam(value = "Apply the config to all pre-existing descendants", required = false) + @QueryParam("recurse") @DefaultValue("false") final Boolean recurse, + @ApiParam(value = "Value to set") + Object newValue); + // deletion of config is not supported; you can set it null } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/LocationApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/LocationApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/LocationApi.java index 1134202..4b6e32f 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/LocationApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/LocationApi.java @@ -47,42 +47,40 @@ import com.wordnik.swagger.core.ApiParam; @Consumes(MediaType.APPLICATION_JSON) public interface LocationApi { - @GET - @ApiOperation(value = "Fetch the list of locations", - responseClass = "brooklyn.rest.domain.LocationSummary", - multiValueResponse = true) - public List<LocationSummary> list() ; + @GET + @ApiOperation(value = "Fetch the list of locations", + responseClass = "brooklyn.rest.domain.LocationSummary", + multiValueResponse = true) + public List<LocationSummary> list(); + // this is here to support the web GUI's circles + @GET + @Path("/usage/LocatedLocations") + @ApiOperation(value = "Return a summary of all usage", notes="interim API, expected to change") + public Map<String,Map<String,Object>> getLocatedLocations(); - // this is here to support the web GUI's circles - @GET - @Path("/usage/LocatedLocations") - @ApiOperation(value = "Return a summary of all usage", notes="interim API, expected to change") - public Map<String,Map<String,Object>> getLocatedLocations() ; + @GET + @Path("/{locationId}") + @ApiOperation(value = "Fetch details about a location", + responseClass = "brooklyn.rest.domain.LocationSummary", + multiValueResponse = true) + public LocationSummary get( + @ApiParam(value = "Location id to fetch", required = true) + @PathParam("locationId") String locationId, + @ApiParam(value = "Whether full (inherited) config should be compiled", required = false) + @DefaultValue("false") + @QueryParam("full") String fullConfig); - @GET - @Path("/{locationId}") - @ApiOperation(value = "Fetch details about a location", - responseClass = "brooklyn.rest.domain.LocationSummary", - multiValueResponse = true) - public LocationSummary get( - @ApiParam(value = "Location id to fetch", required = true) - @PathParam("locationId") String locationId, - @ApiParam(value = "Whether full (inherited) config should be compiled", required = false) - @DefaultValue("false") - @QueryParam("full") String fullConfig) ; - - @POST - @ApiOperation(value = "Create a new location", responseClass = "String") - public Response create( - @ApiParam(name = "locationSpec", value = "Location specification object", required = true) - @Valid LocationSpec locationSpec) ; - - @DELETE - @Path("/{locationId}") - @ApiOperation(value = "Delete a location object by id") - public void delete( - @ApiParam(value = "Location id to delete", required = true) - @PathParam("locationId") String locationId) ; + @POST + @ApiOperation(value = "Create a new location", responseClass = "String") + public Response create( + @ApiParam(name = "locationSpec", value = "Location specification object", required = true) + @Valid LocationSpec locationSpec); + @DELETE + @Path("/{locationId}") + @ApiOperation(value = "Delete a location object by id") + public void delete( + @ApiParam(value = "Location id to delete", required = true) + @PathParam("locationId") String locationId); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyApi.java index 7154ca5..72a91f5 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyApi.java @@ -38,120 +38,114 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) public interface PolicyApi { - @GET - @ApiOperation(value = "Fetch the policies attached to a specific application entity", - responseClass = "brooklyn.rest.domain.PolicySummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<PolicySummary> list( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken - ) ; - - // TODO support parameters ?show=value,summary&name=xxx - // (and in sensors class) - @GET - @Path("/current-state") - @ApiOperation(value = "Fetch policy states in batch", notes="Returns a map of policy ID to whether it is active") - // FIXME method name -- this is nothing to do with config! - public Map<String, Boolean> batchConfigRead( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken) ; - - @POST - @ApiOperation(value = "Add a policy", notes = "Returns a summary of the new policy") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity"), - @ApiError(code = 400, reason = "Type is not a class implementing Policy") - }) - public PolicySummary addPolicy( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "policyType", value = "Class of policy to add", required = true) - @QueryParam("type") - String policyTypeName, - - // TODO would like to make this optional but jersey complains if we do - @ApiParam(name = "config", value = "Configuration for the policy (as key value pairs)", required = true) - Map<String, String> config - ) ; - - @GET - @Path("/{policy}") - @ApiOperation(value = "Gets status of a policy (RUNNING / SUSPENDED)") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or policy") - }) - public Status getStatus( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "policy", value = "Policy ID or name", required = true) - @PathParam("policy") String policyId - ) ; - - @POST - @Path("/{policy}/start") - @ApiOperation(value = "Start or resume a policy") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or policy") - }) - public Response start( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "policy", value = "Policy ID or name", required = true) - @PathParam("policy") String policyId - ) ; - - @POST - @Path("/{policy}/stop") - @ApiOperation(value = "Suspends a policy") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or policy") - }) - public Response stop( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "policy", value = "Policy ID or name", required = true) - @PathParam("policy") String policyId - ) ; - - // TODO: Should be DELETE /policy, not POST /policy/destroy - @POST - @Path("/{policy}/destroy") - @ApiOperation(value = "Destroy a policy", notes="Removes a policy from being associated with the entity and destroys it (stopping first if running)") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or policy") - }) - public Response destroy( - @ApiParam(name = "application", value = "Application ID or name", required = true) - @PathParam("application") String application, - - @ApiParam(name = "entity", value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - - @ApiParam(name = "policy", value = "Policy ID or name", required = true) - @PathParam("policy") String policyToken - ) ; + @GET + @ApiOperation(value = "Fetch the policies attached to a specific application entity", + responseClass = "brooklyn.rest.domain.PolicySummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<PolicySummary> list( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken); + + // TODO support parameters ?show=value,summary&name=xxx + // (and in sensors class) + @GET + @Path("/current-state") + @ApiOperation(value = "Fetch policy states in batch", notes="Returns a map of policy ID to whether it is active") + // FIXME method name -- this is nothing to do with config! + public Map<String, Boolean> batchConfigRead( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken) ; + + @POST + @ApiOperation(value = "Add a policy", notes = "Returns a summary of the new policy") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity"), + @ApiError(code = 400, reason = "Type is not a class implementing Policy") + }) + public PolicySummary addPolicy( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "policyType", value = "Class of policy to add", required = true) + @QueryParam("type") + String policyTypeName, + + // TODO would like to make this optional but jersey complains if we do + @ApiParam(name = "config", value = "Configuration for the policy (as key value pairs)", required = true) + Map<String, String> config); + + @GET + @Path("/{policy}") + @ApiOperation(value = "Gets status of a policy (RUNNING / SUSPENDED)") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or policy") + }) + public Status getStatus( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "policy", value = "Policy ID or name", required = true) + @PathParam("policy") String policyId); + + @POST + @Path("/{policy}/start") + @ApiOperation(value = "Start or resume a policy") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or policy") + }) + public Response start( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "policy", value = "Policy ID or name", required = true) + @PathParam("policy") String policyId); + + @POST + @Path("/{policy}/stop") + @ApiOperation(value = "Suspends a policy") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or policy") + }) + public Response stop( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "policy", value = "Policy ID or name", required = true) + @PathParam("policy") String policyId); + + // TODO: Should be DELETE /policy, not POST /policy/destroy + @POST + @Path("/{policy}/destroy") + @ApiOperation(value = "Destroy a policy", notes="Removes a policy from being associated with the entity and destroys it (stopping first if running)") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or policy") + }) + public Response destroy( + @ApiParam(name = "application", value = "Application ID or name", required = true) + @PathParam("application") String application, + + @ApiParam(name = "entity", value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + + @ApiParam(name = "policy", value = "Policy ID or name", required = true) + @PathParam("policy") String policyToken); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyConfigApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyConfigApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyConfigApi.java index 235a777..79e1614 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyConfigApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/PolicyConfigApi.java @@ -37,89 +37,84 @@ import java.util.Map; @Consumes(MediaType.APPLICATION_JSON) public interface PolicyConfigApi { - @GET - @ApiOperation(value = "Fetch the config keys for a specific policy", - responseClass = "brooklyn.rest.domain.ConfigSummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity or policy") - }) - public List<PolicyConfigSummary> list( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Policy ID or name", required = true) - @PathParam("policy") final String policyToken - ) ; + @GET + @ApiOperation(value = "Fetch the config keys for a specific policy", + responseClass = "brooklyn.rest.domain.ConfigSummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity or policy") + }) + public List<PolicyConfigSummary> list( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Policy ID or name", required = true) + @PathParam("policy") final String policyToken); - // TODO support parameters ?show=value,summary&name=xxx &format={string,json,xml} - // (and in sensors class) - @GET - @Path("/current-state") - @ApiOperation(value = "Fetch config key values in batch", notes="Returns a map of config name to value") - public Map<String, Object> batchConfigRead( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Policy ID or name", required = true) - @PathParam("policy") String policyToken) ; + // TODO support parameters ?show=value,summary&name=xxx &format={string,json,xml} + // (and in sensors class) + @GET + @Path("/current-state") + @ApiOperation(value = "Fetch config key values in batch", notes="Returns a map of config name to value") + public Map<String, Object> batchConfigRead( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Policy ID or name", required = true) + @PathParam("policy") String policyToken) ; - @GET - @Path("/{config}") - @ApiOperation(value = "Fetch config value", responseClass = "Object") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") - }) - public String get( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Policy ID or name", required = true) - @PathParam("policy") String policyToken, - @ApiParam(value = "Config key ID", required = true) - @PathParam("config") String configKeyName - ) ; - - /** @deprecated since 0.7.0 use set with object*/ @Deprecated - @POST - @Path("/{config}/set") - @ApiOperation(value = "Sets the given config on this policy") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") - }) - public Response set( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Policy ID or name", required = true) - @PathParam("policy") String policyToken, - @ApiParam(value = "Config key ID", required = true) - @PathParam("config") String configKeyName, - @ApiParam(name = "value", value = "New value for the configuration", required = true) - @QueryParam("value") String value - ) ; - - @POST - @Path("/{config}") - @ApiOperation(value = "Sets the given config on this policy") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") - }) - public Response set( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") String entityToken, - @ApiParam(value = "Policy ID or name", required = true) - @PathParam("policy") String policyToken, - @ApiParam(value = "Config key ID", required = true) - @PathParam("config") String configKeyName, - @ApiParam(name = "value", value = "New value for the configuration", required = true) - Object value - ) ; + @GET + @Path("/{config}") + @ApiOperation(value = "Fetch config value", responseClass = "Object") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") + }) + public String get( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Policy ID or name", required = true) + @PathParam("policy") String policyToken, + @ApiParam(value = "Config key ID", required = true) + @PathParam("config") String configKeyName); + /** @deprecated since 0.7.0 use set with object*/ @Deprecated + @POST + @Path("/{config}/set") + @ApiOperation(value = "Sets the given config on this policy") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") + }) + public Response set( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Policy ID or name", required = true) + @PathParam("policy") String policyToken, + @ApiParam(value = "Config key ID", required = true) + @PathParam("config") String configKeyName, + @ApiParam(name = "value", value = "New value for the configuration", required = true) + @QueryParam("value") String value); + + @POST + @Path("/{config}") + @ApiOperation(value = "Sets the given config on this policy") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity, policy or config key") + }) + public Response set( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") String entityToken, + @ApiParam(value = "Policy ID or name", required = true) + @PathParam("policy") String policyToken, + @ApiParam(value = "Config key ID", required = true) + @PathParam("config") String configKeyName, + @ApiParam(name = "value", value = "New value for the configuration", required = true) + Object value); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/ScriptApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ScriptApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ScriptApi.java index db56a17..23e172f 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/ScriptApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ScriptApi.java @@ -44,11 +44,9 @@ public interface ScriptApi { @Path("/groovy") @Consumes("application/text") @ApiOperation(value = "Execute a groovy script", - responseClass = "brooklyn.rest.domain.SensorSummary") + responseClass = "brooklyn.rest.domain.SensorSummary") public ScriptExecutionSummary groovy( @Context HttpServletRequest request, @ApiParam(name = "script", value = "Groovy script to execute", required = true) - String script - ) ; - + String script); }
