http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java deleted file mode 100644 index 916786c..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.api; - -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import brooklyn.rest.apidoc.Apidoc; -import brooklyn.rest.domain.SensorSummary; - -import com.wordnik.swagger.core.ApiError; -import com.wordnik.swagger.core.ApiErrors; -import com.wordnik.swagger.core.ApiOperation; -import com.wordnik.swagger.core.ApiParam; - -@Path("/v1/applications/{application}/entities/{entity}/sensors") -@Apidoc("Entity Sensors") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface SensorApi { - - @GET - @ApiOperation(value = "Fetch the sensor list for a specific application entity", - responseClass = "brooklyn.rest.domain.SensorSummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<SensorSummary> 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 - @Path("/current-state") - @ApiOperation(value = "Fetch sensor values in batch", notes="Returns a map of sensor name to value") - public Map<String, Object> batchSensorRead( - @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 = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw); - - @GET - @Path("/{sensor}") - @ApiOperation(value = "Fetch sensor value (json)", responseClass = "Object") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - public Object get( - @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 = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw); - - // this method is used if user has requested plain (ie not converting to json) - @GET - @Path("/{sensor}") - @ApiOperation(value = "Fetch sensor value (text/plain)", responseClass = "String") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - @Produces(MediaType.TEXT_PLAIN) - public String getPlain( - @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 = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw); - - @POST - @ApiOperation(value = "Manually set multiple sensor 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 = "Map of sensor names to values", required = true) - Map newValues); - - @POST - @Path("/{sensor}") - @ApiOperation(value = "Manually set a sensor value") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - 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 = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Value to set") - Object newValue); - - @DELETE - @Path("/{sensor}") - @ApiOperation(value = "Manually clear a sensor value") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - public void delete( - @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 = "Sensor name", required = true) - @PathParam("sensor") String sensorName); -}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java deleted file mode 100644 index d779f68..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.api; - -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import brooklyn.management.ha.HighAvailabilityMode; -import brooklyn.management.ha.ManagementNodeState; -import brooklyn.rest.apidoc.Apidoc; -import brooklyn.rest.domain.HighAvailabilitySummary; -import brooklyn.rest.domain.VersionSummary; - -import com.google.common.annotations.Beta; -import com.wordnik.swagger.core.ApiError; -import com.wordnik.swagger.core.ApiErrors; -import com.wordnik.swagger.core.ApiOperation; -import com.wordnik.swagger.core.ApiParam; - -@Path("/v1/server") -@Apidoc("Server") -@Produces(MediaType.APPLICATION_JSON) -@Beta -public interface ServerApi { - - public final String MIME_TYPE_ZIP = "applicaiton/zip"; - // TODO support TGZ, and check mime type - public final String MIME_TYPE_TGZ = "applicaiton/gzip"; - - @POST - @Path("/properties/reload") - @ApiOperation(value = "Reload brooklyn.properties") - public void reloadBrooklynProperties(); - - @POST - @Path("/shutdown") - @ApiOperation(value = "Terminate this Brooklyn server instance") - @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) - public void shutdown( - @ApiParam(name = "stopAppsFirst", value = "Whether to stop running applications before shutting down") - @FormParam("stopAppsFirst") @DefaultValue("false") boolean stopAppsFirst, - @ApiParam(name = "forceShutdownOnError", value ="Force shutdown if apps fail to stop or timeout") - @FormParam("forceShutdownOnError") @DefaultValue("false") boolean forceShutdownOnError, - @ApiParam(name = "shutdownTimeout", value = "A maximum delay to wait for apps to gracefully stop before giving up or forcibly exiting, 0 to wait infinitely") - @FormParam("shutdownTimeout") @DefaultValue("20s") String shutdownTimeout, - @ApiParam(name = "requestTimeout", value = "Maximum time to block the request for the shutdown to finish, 0 to wait infinitely") - @FormParam("requestTimeout") @DefaultValue("20s") String requestTimeout, - @ApiParam(name = "delayForHttpReturn", value = "The delay before exiting the process, to permit the REST response to be returned") - @FormParam("delayForHttpReturn") @DefaultValue("5s") String delayForHttpReturn, - @ApiParam(name = "delayMillis", value = "Deprecated, analogous to delayForHttpReturn") - @FormParam("delayMillis") Long delayMillis); - - @GET - @Path("/version") - @ApiOperation(value = "Return version identifier information for this Brooklyn instance", responseClass = "String", multiValueResponse = false) - public VersionSummary getVersion(); - - @GET - @Path("/up") - @ApiOperation(value = "Returns whether this server is up - fully started, and not stopping, though it may have errors") - public boolean isUp(); - - @GET - @Path("/shuttingDown") - @ApiOperation(value = "Returns whether this server is shutting down") - public boolean isShuttingDown(); - - @GET - @Path("/healthy") - @ApiOperation(value = "Returns whether this node is healthy - fully started, not stopping, and no errors") - public boolean isHealthy(); - - @Deprecated /** @deprecated since 0.7.0 use /ha/node (which returns correct JSON) */ - @GET - @Path("/status") - @ApiOperation(value = "Returns the status of this Brooklyn instance [DEPRECATED; see ../ha/state]", - responseClass = "String", - multiValueResponse = false) - public String getStatus(); - - @GET - @Path("/up/extended") - @ApiOperation(value = "Returns extended server-up information, a map including up (/up), shuttingDown (/shuttingDown), healthy (/healthy), and ha (/ha/states) (qv)") - public Map<String,Object> getUpExtended(); - - @GET - @Path("/config/{configKey}") - @ApiOperation(value = "Get the value of the specified config key from brooklyn properties") - @ApiErrors(value = { - // TODO: This should probably return a 404 if the key is not present, and should return a predictable - // value if the value is not set. Behaviour should be consistent with EntityConfigApi.get() - @ApiError(code = 204, reason = "Could not find config key") - }) - public String getConfig( - @ApiParam(value = "Config key ID", required = true) - @PathParam("configKey") String configKey); - - @Deprecated /** @deprecated since 0.7.0 use /ha/states */ - @GET - @Path("/highAvailability") - @ApiOperation(value = "Returns the status of all Brooklyn instances in the management plane [DEPRECATED; see ../ha/states]", - responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") - public HighAvailabilitySummary getHighAvailability(); - - @GET - @Path("/ha/state") - @ApiOperation(value = "Returns the HA state of this management node") - public ManagementNodeState getHighAvailabilityNodeState(); - - @GET - @Path("/ha/metrics") - @ApiOperation(value = "Returns a collection of HA metrics") - public Map<String,Object> getHighAvailabilityMetrics(); - - @POST - @Path("/ha/state") - @ApiOperation(value = "Changes the HA state of this management node") - public ManagementNodeState setHighAvailabilityNodeState( - @ApiParam(name = "mode", value = "The state to change to") - @FormParam("mode") HighAvailabilityMode mode); - - @GET - @Path("/ha/states") - @ApiOperation(value = "Returns the HA states and detail for all nodes in this management plane", - responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") - public HighAvailabilitySummary getHighAvailabilityPlaneStates(); - - @POST - @Path("/ha/states/clear") - @ApiOperation(value = "Clears HA node information for non-master nodes; active nodes will repopulate and other records will be erased") - public Response clearHighAvailabilityPlaneStates(); - - @GET - @Path("/ha/priority") - @ApiOperation(value = "Returns the HA node priority for MASTER failover") - public long getHighAvailabitlityPriority(); - - @POST - @Path("/ha/priority") - @ApiOperation(value = "Sets the HA node priority for MASTER failover") - public long setHighAvailabilityPriority( - @ApiParam(name = "priority", value = "The priority to be set") - @FormParam("priority") long priority); - - @GET - @Produces(MIME_TYPE_ZIP) - @Path("/ha/persist/export") - @ApiOperation(value = "Retrieves the persistence store data, as an archive") - public Response exportPersistenceData( - @ApiParam(name = "origin", value = "Whether to take from LOCAL or REMOTE state; default to AUTO detect, " - + "using LOCAL as master and REMOTE for other notes") - @QueryParam("origin") @DefaultValue("AUTO") String origin); - - // TODO would be nice to allow setting, as a means to recover / control more easily than messing with persistent stores -// @POST -// @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) -// @Path("/ha/persist/import") -// @ApiOperation(value = "Causes the supplied persistence data (tgz) to be imported and added " -// + "(fails if the node is not master), optionally removing any items not referenced") -// public Response importPersistenceData( -// // question: do we want the MementoCopyMode, cf export above? -// @ApiParam(name = "clearOthers", value = "Whether to clear all existing items before adding these", required = false, defaultValue = "false") -// @FormParam("clearOthers") Boolean clearOthers, -// @ApiParam(name = "data", -// value = "TGZ contents of a persistent directory to be imported", required = true) -// @Valid String dataTgz); - - // TODO /ha/persist/backup set of endpoints, to list and retrieve specific backups - - @GET - @Path("/user") - @ApiOperation(value = "Return user information for this Brooklyn instance", - responseClass = "String", multiValueResponse = false) - public String getUser(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/api/UsageApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/UsageApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/UsageApi.java deleted file mode 100644 index ef06eb6..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/UsageApi.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.api; - -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import brooklyn.rest.apidoc.Apidoc; -import brooklyn.rest.domain.UsageStatistics; - -import com.wordnik.swagger.core.ApiError; -import com.wordnik.swagger.core.ApiErrors; -import com.wordnik.swagger.core.ApiOperation; -import com.wordnik.swagger.core.ApiParam; - -@Path("/v1/usage") -@Apidoc("Usage") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface UsageApi { - - // TODO should `/applications?start=...` only return those applications matching the constraint? - // Or return all applications, but with empty statistics for some? - // Currently it returns only those applications that match. - - @GET - @Path("/applications") - @ApiOperation( - value = "Retrieve usage information about all applications", - responseClass = "brooklyn.rest.domain.UsageStatistics" - ) - @ApiErrors(value = {}) - public List<UsageStatistics> listApplicationsUsage( - @ApiParam( - name = "start", - value = "timestamp of start marker for usage reporting, in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("start") String startDate, - @ApiParam( - name = "end", - value = "timestamp of end marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("end") String endDate) ; - - @GET - @Path("/applications/{application}") - @ApiOperation( - value = "Retrieve usage information about a specified application", - responseClass = "brooklyn.rest.domain.UsageStatistics" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application not found") - }) - public UsageStatistics getApplicationUsage( - @ApiParam( - name = "application", - value = "Application id", - required = true - ) - @PathParam("application") String applicationId, - @ApiParam( - name = "start", - value = "timestamp of start marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("start") String startDate, - @ApiParam( - name = "end", - value = "timestamp of end marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("end") String endDate) ; - - @GET - @Path("/machines") - @ApiOperation( - value = "Retrieve usage information about all machine locations, optionally filtering for a specific application and/or time range", - responseClass = "brooklyn.rest.domain.UsageStatistics" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Application not found") - }) - public List<UsageStatistics> listMachinesUsage( - @ApiParam( - name = "application", - value = "Application id", - required = false - ) - @QueryParam("application") String application, - @ApiParam( - name = "start", - value = "timestamp of start marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("start") String startDate, - @ApiParam( - name = "end", - value = "timestamp of end marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("end") String endDate) ; - - @GET - @Path("/machines/{machine}") - @ApiOperation( - value = "Retrieve usage information about a specific machine location", - responseClass = "brooklyn.rest.domain.UsageStatistics" - ) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Machine not found") - }) - public UsageStatistics getMachineUsage( - @ApiParam( - name = "machine", - value = "Machine id", - required = true - ) - @PathParam("machine") String machine, - @ApiParam( - name = "start", - value = "timestamp of start marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("start") String startDate, - @ApiParam( - name = "end", - value = "timestamp of end marker for usage reporting in format UTC millis or yyyy-MM-dd'T'HH:mm:ssZ", - required = false - ) - @QueryParam("end") String endDate) ; -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java deleted file mode 100644 index 905e0fc..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.api; - -import brooklyn.rest.apidoc.Apidoc; -import com.wordnik.swagger.core.ApiOperation; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -@Path("/v1/version") -@Apidoc("Version") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -/** @deprecated since 0.7.0; use /v1/server/version */ -@Deprecated -public interface VersionApi { - - @GET - @ApiOperation(value = "Return version identifier information for this Brooklyn instance; deprecated, use /server/version", - responseClass = "String", multiValueResponse = false) - public String getVersion(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/AccessSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/AccessSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/AccessSummary.java deleted file mode 100644 index 9456a23..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/AccessSummary.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.io.Serializable; -import java.net.URI; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -@Beta -public class AccessSummary implements Serializable { - - private static final long serialVersionUID = 5097292906225042890L; - - private final boolean locationProvisioningAllowed; - private final Map<String, URI> links; - - public AccessSummary( - @JsonProperty("locationProvisioningAllowed") boolean locationProvisioningAllowed, - @JsonProperty("links") Map<String, URI> links - ) { - this.locationProvisioningAllowed = locationProvisioningAllowed; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - public boolean isLocationProvisioningAllowed() { - return locationProvisioningAllowed; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof AccessSummary)) return false; - AccessSummary other = (AccessSummary) o; - return locationProvisioningAllowed == other.isLocationProvisioningAllowed(); - } - - @Override - public int hashCode() { - return Objects.hashCode(locationProvisioningAllowed); - } - - @Override - public String toString() { - return "AccessSummary{" + - "locationProvisioningAllowed='" + locationProvisioningAllowed + '\'' + - ", links=" + links + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/ApiError.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApiError.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ApiError.java deleted file mode 100644 index 83baa8f..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApiError.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import brooklyn.util.text.Strings; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Throwables; - -public class ApiError implements Serializable { - - private static final long serialVersionUID = -8244515572813244686L; - - public static Builder builder() { - return new Builder(); - } - - public static ApiError of(Throwable t) { - return builderFromThrowable(t).build(); - } - - public static ApiError of(String message) { - return builder().message(message).build(); - } - - /** @deprecated since 0.7.0; use {@link #builderFromThrowable(Throwable)} */ - @Deprecated - public static Builder fromThrowable(Throwable t) { - return builderFromThrowable(t); - } - - /** - * @return An {@link ApiError.Builder} whose message is initialised to either the throwable's - * message or the throwable's class name if the message is null and whose details are - * initialised to the throwable's stack trace. - */ - public static Builder builderFromThrowable(Throwable t) { - checkNotNull(t, "throwable"); - String message = Optional.fromNullable(t.getMessage()) - .or(t.getClass().getName()); - return builder() - .message(message) - .details(Throwables.getStackTraceAsString(t)); - } - - public static class Builder { - private String message; - private String details; - private Integer errorCode; - - public Builder message(String message) { - this.message = checkNotNull(message, "message"); - return this; - } - - public Builder details(String details) { - this.details = checkNotNull(details, "details"); - return this; - } - - public Builder errorCode(Status errorCode) { - return errorCode(errorCode.getStatusCode()); - } - - public Builder errorCode(Integer errorCode) { - this.errorCode = errorCode; - return this; - } - - /** as {@link #prefixMessage(String, String)} with default separator of `: ` */ - public Builder prefixMessage(String prefix) { - return prefixMessage(prefix, ": "); - } - - /** puts a prefix in front of the message, with the given separator if there is already a message; - * if there is no message, it simply sets the prefix as the message - */ - public Builder prefixMessage(String prefix, String separatorIfMessageNotBlank) { - if (Strings.isBlank(message)) message(prefix); - else message(prefix+separatorIfMessageNotBlank+message); - return this; - } - - public ApiError build() { - return new ApiError(message, details, errorCode); - } - - /** @deprecated since 0.7.0; use {@link #copy(ApiError)} */ - @Deprecated - public Builder fromApiError(ApiError error) { - return copy(error); - } - - public Builder copy(ApiError error) { - return this - .message(error.message) - .details(error.details) - .errorCode(error.error); - } - - public String getMessage() { - return message; - } - } - - private final String message; - - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final String details; - - @JsonSerialize(include=Inclusion.NON_NULL) - private final Integer error; - - public ApiError(String message) { this(message, null); } - public ApiError(String message, String details) { this(message, details, null); } - public ApiError( - @JsonProperty("message") String message, - @JsonProperty("details") String details, - @JsonProperty("error") Integer error) { - this.message = checkNotNull(message, "message"); - this.details = details != null ? details : ""; - this.error = error; - } - - public String getMessage() { - return message; - } - - public String getDetails() { - return details; - } - - public Integer getError() { - return error; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (other == null || getClass() != other.getClass()) return false; - ApiError that = ApiError.class.cast(other); - return Objects.equal(this.message, that.message) && - Objects.equal(this.details, that.details) && - Objects.equal(this.error, that.error); - } - - @Override - public int hashCode() { - return Objects.hashCode(message, details, error); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("message", message) - .add("details", details) - .add("error", error) - .toString(); - } - - public Response asBadRequestResponseJson() { - return asResponse(Status.BAD_REQUEST, MediaType.APPLICATION_JSON_TYPE); - } - - public Response asResponse(Status defaultStatus, MediaType type) { - return Response.status(error!=null ? error : defaultStatus!=null ? defaultStatus.getStatusCode() : Status.INTERNAL_SERVER_ERROR.getStatusCode()) - .type(type) - .entity(this) - .build(); - } - - public Response asResponse(MediaType type) { - return asResponse(null, type); - } - - public Response asJsonResponse() { - return asResponse(MediaType.APPLICATION_JSON_TYPE); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java deleted file mode 100644 index 761f365..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -public class ApplicationSpec implements HasName, Serializable { - - private static final long serialVersionUID = -7090404504233835343L; - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String name; - private String type; - private Set<EntitySpec> entities; - private Set<String> locations; - private Map<String, String> config; - - public Builder from(ApplicationSpec spec) { - this.name = spec.name; - this.entities = spec.entities; - this.locations = spec.locations; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder type(String type) { - this.type = type; - return this; - } - - public Builder entities(Set<EntitySpec> entities) { - this.entities = entities; - return this; - } - - public Builder locations(Set<String> locations) { - this.locations = locations; - return this; - } - - public Builder config(Map<String, String> config) { - this.config = config; - return this; - } - - public ApplicationSpec build() { - return new ApplicationSpec(name, type, entities, locations, config); - } - } - - private final String name; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String type; - @JsonSerialize(include = Inclusion.NON_NULL) - private final Set<EntitySpec> entities; - private final Set<String> locations; - @JsonSerialize(include = Inclusion.NON_EMPTY) - private final Map<String, String> config; - - public ApplicationSpec( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("entities") Set<EntitySpec> entities, - @JsonProperty("locations") Collection<String> locations, - @JsonProperty("config") Map<String, String> config) { - this.name = name; - this.type = type; - if (entities==null) { - this.entities = null; - } else { - this.entities = (entities.isEmpty() && type!=null) ? null : ImmutableSet.copyOf(entities); - } - this.locations = ImmutableSet.copyOf(checkNotNull(locations, "locations must be provided for an application spec")); - this.config = config == null ? Collections.<String, String>emptyMap() : ImmutableMap.<String, String>copyOf(config); - if (this.entities!=null && this.type!=null) throw new IllegalStateException("cannot supply both type and entities for an application spec"); - // valid for both to be null, e.g. for an anonymous type -// if (this.entities==null && this.type==null) throw new IllegalStateException("must supply either type or entities for an application spec"); - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public Set<EntitySpec> getEntities() { - return entities; - } - - public Set<String> getLocations() { - return locations; - } - - public Map<String, String> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - ApplicationSpec that = (ApplicationSpec) o; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (type != null ? !type.equals(that.type) : that.type != null) - return false; - if (entities != null ? !entities.equals(that.entities) : that.entities != null) - return false; - if (locations != null ? !locations.equals(that.locations) : that.locations != null) - return false; - if (config != null ? !config.equals(that.config) : that.config != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (entities != null ? entities.hashCode() : 0); - result = 31 * result + (locations != null ? locations.hashCode() : 0); - result = 31 * result + (config != null ? config.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ApplicationSpec{" - + "name='" + name + '\'' - + ", type=" + type - + ", entitySpecs=" + entities - + ", locations=" + locations - + ", config=" + config - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSummary.java deleted file mode 100644 index 8370fee..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSummary.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; -import java.net.URI; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.collect.ImmutableMap; - -public class ApplicationSummary implements HasId, Serializable { - - private static final long serialVersionUID = -247411021540729088L; - - private final static Map<Status, Status> validTransitions = - ImmutableMap.<Status, Status>builder() - .put(Status.UNKNOWN, Status.ACCEPTED) - .put(Status.ACCEPTED, Status.STARTING) - .put(Status.STARTING, Status.RUNNING) - .put(Status.RUNNING, Status.STOPPING) - .put(Status.STOPPING, Status.STOPPED) - .put(Status.STOPPED, Status.STARTING) - .build(); - - private final String id; - private final ApplicationSpec spec; - private final Status status; - private final Map<String, URI> links; - - public ApplicationSummary( - @JsonProperty("id") String id, - @JsonProperty("spec") ApplicationSpec spec, - @JsonProperty("status") Status status, - @JsonProperty("links") Map<String, URI> links - ) { - this.id = id; - this.spec = checkNotNull(spec, "spec"); - this.status = checkNotNull(status, "status"); - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - @Override - public String getId() { - return id; - } - - public ApplicationSpec getSpec() { - return spec; - } - - public Status getStatus() { - return status; - } - - public Map<String, URI> getLinks() { - return links; - } - - public ApplicationSummary transitionTo(Status newStatus) { - if (newStatus == Status.ERROR || validTransitions.get(status) == newStatus) { - return new ApplicationSummary(id, spec, newStatus, links); - } - throw new IllegalStateException("Invalid transition from '" + - status + "' to '" + newStatus + "'"); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ApplicationSummary that = (ApplicationSummary) o; - - if (spec != null ? !spec.equals(that.spec) : that.spec != null) - return false; - if (status != that.status) return false; - - return true; - } - - @Override - public int hashCode() { - int result = spec != null ? spec.hashCode() : 0; - result = 31 * result + (status != null ? status.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Application{" + - "id=" + id + - ", spec=" + spec + - ", status=" + status + - '}'; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/BrooklynFeatureSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/BrooklynFeatureSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/BrooklynFeatureSummary.java deleted file mode 100644 index 461be65..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/BrooklynFeatureSummary.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package brooklyn.rest.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.collect.Maps; - -public class BrooklynFeatureSummary implements Serializable { - - private static final long serialVersionUID = 4595452639602650453L; - - private final String name; - private final String symbolicName; - private final String version; - private final String lastModified; - private Map<String, String> additionalData = Maps.newHashMap(); - - public BrooklynFeatureSummary( - @JsonProperty("name") String name, - @JsonProperty("symbolicName") String symbolicName, - @JsonProperty("version") String version, - @JsonProperty("lastModified") String lastModified) { - this.symbolicName = checkNotNull(symbolicName, "symbolicName"); - this.name = name; - this.version = version; - this.lastModified = lastModified; - } - - public BrooklynFeatureSummary(String name, String symbolicName, String version, String lastModified, Map<String, String> additionalData) { - this(name, symbolicName, version, lastModified); - this.additionalData = additionalData; - } - - @JsonIgnore - public Map<String, String> getAdditionalData() { - return additionalData; - } - - public String getLastModified() { - return lastModified; - } - - public String getName() { - return name; - } - - public String getSymbolicName() { - return symbolicName; - } - - public String getVersion() { - return version; - } - - @JsonAnyGetter - private Map<String, String> any() { - return additionalData; - } - - @JsonAnySetter - private void set(String name, String value) { - additionalData.put(name, value); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java deleted file mode 100644 index 268437a..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -public class CatalogEntitySummary extends CatalogItemSummary { - - private static final long serialVersionUID = 1063908984191424539L; - - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Set<EntityConfigSummary> config; - - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Set<SensorSummary> sensors; - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Set<EffectorSummary> effectors; - - public CatalogEntitySummary( - @JsonProperty("symbolicName") String symbolicName, - @JsonProperty("version") String version, - @JsonProperty("name") String name, - @JsonProperty("javaType") String javaType, - @JsonProperty("planYaml") String planYaml, - @JsonProperty("description") String description, - @JsonProperty("iconUrl") String iconUrl, - @JsonProperty("config") Set<EntityConfigSummary> config, - @JsonProperty("sensors") Set<SensorSummary> sensors, - @JsonProperty("effectors") Set<EffectorSummary> effectors, - @JsonProperty("deprecated") boolean deprecated, - @JsonProperty("links") Map<String, URI> links - ) { - super(symbolicName, version, name, javaType, planYaml, description, iconUrl, deprecated, links); - this.config = config; - this.sensors = sensors; - this.effectors = effectors; - } - - public Set<EntityConfigSummary> getConfig() { - return config; - } - - public Set<SensorSummary> getSensors() { - return sensors; - } - - public Set<EffectorSummary> getEffectors() { - return effectors; - } - - @Override - public String toString() { - return super.toString()+"["+ - "config="+getConfig()+"; " + - "sensors="+getSensors()+"; "+ - "effectors="+getEffectors()+"; "+ - "deprecated="+isDeprecated()+"]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java deleted file mode 100644 index 79b1d27..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.io.Serializable; -import java.net.URI; -import java.util.Map; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -/** variant of Catalog*ItemDto objects for JS/JSON serialization; - * see also, subclasses */ -@JsonIgnoreProperties(ignoreUnknown = true) -// ignore unknown, ie properties from subclasses (entity) -public class CatalogItemSummary implements HasId, HasName, Serializable { - - private static final long serialVersionUID = -823483595879417681L; - - private final String id; - private final String symbolicName; - private final String version; - - //needed for backwards compatibility only (json serializer works on fields, not getters) - @Deprecated - private final String type; - - private final String javaType; - - private final String name; - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final String description; - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final String iconUrl; - private final String planYaml; - private final boolean deprecated; - - private final Map<String, URI> links; - - public CatalogItemSummary( - @JsonProperty("symbolicName") String symbolicName, - @JsonProperty("version") String version, - @JsonProperty("name") String displayName, - @JsonProperty("javaType") String javaType, - @JsonProperty("planYaml") String planYaml, - @JsonProperty("description") String description, - @JsonProperty("iconUrl") String iconUrl, - @JsonProperty("deprecated") boolean deprecated, - @JsonProperty("links") Map<String, URI> links - ) { - this.id = symbolicName + ":" + version; - this.symbolicName = symbolicName; - this.type = symbolicName; - this.version = version; - this.name = displayName; - this.javaType = javaType; - this.planYaml = planYaml; - this.description = description; - this.iconUrl = iconUrl; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - this.deprecated = deprecated; - } - - @Override - public String getId() { - return id; - } - - public String getSymbolicName() { - return symbolicName; - } - - public String getVersion() { - return version; - } - - public String getJavaType() { - return javaType; - } - - public String getType() { - return type; - } - - public String getPlanYaml() { - return planYaml; - } - - @Override - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public String getIconUrl() { - return iconUrl; - } - - public Map<String, URI> getLinks() { - return links; - } - - public boolean isDeprecated() { - return deprecated; - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("id", symbolicName) - .add("version", version) - .add("deprecated", deprecated) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hashCode(symbolicName, version, name, javaType, deprecated); - } - - @Override - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogLocationSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogLocationSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogLocationSummary.java deleted file mode 100644 index 874b848..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogLocationSummary.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.collect.ImmutableSet; - -public class CatalogLocationSummary extends CatalogItemSummary { - - private final Set<LocationConfigSummary> config; - - public CatalogLocationSummary( - @JsonProperty("symbolicName") String symbolicName, - @JsonProperty("version") String version, - @JsonProperty("name") String name, - @JsonProperty("javaType") String javaType, - @JsonProperty("planYaml") String planYaml, - @JsonProperty("description") String description, - @JsonProperty("iconUrl") String iconUrl, - @JsonProperty("config") Set<LocationConfigSummary> config, - @JsonProperty("deprecated") boolean deprecated, - @JsonProperty("links") Map<String, URI> links - ) { - super(symbolicName, version, name, javaType, planYaml, description, iconUrl, deprecated, links); - // TODO expose config from policies - this.config = (config == null) ? ImmutableSet.<LocationConfigSummary>of() : config; - } - - public Set<LocationConfigSummary> getConfig() { - return config; - } - - @Override - public String toString() { - return super.toString()+"["+ - "config="+getConfig()+"]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java deleted file mode 100644 index 75cc6ae..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.collect.ImmutableSet; - -public class CatalogPolicySummary extends CatalogItemSummary { - - private static final long serialVersionUID = -588856488327394445L; - - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Set<PolicyConfigSummary> config; - - public CatalogPolicySummary( - @JsonProperty("symbolicName") String symbolicName, - @JsonProperty("version") String version, - @JsonProperty("name") String name, - @JsonProperty("javaType") String javaType, - @JsonProperty("planYaml") String planYaml, - @JsonProperty("description") String description, - @JsonProperty("iconUrl") String iconUrl, - @JsonProperty("config") Set<PolicyConfigSummary> config, - @JsonProperty("deprecated") boolean deprecated, - @JsonProperty("links") Map<String, URI> links - ) { - super(symbolicName, version, name, javaType, planYaml, description, iconUrl, deprecated, links); - // TODO expose config from policies - this.config = (config == null) ? ImmutableSet.<PolicyConfigSummary>of() : config; - } - - public Set<PolicyConfigSummary> getConfig() { - return config; - } - - @Override - public String toString() { - return super.toString()+"["+ - "config="+getConfig()+"]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java deleted file mode 100644 index 676525c..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.io.Serializable; -import java.net.URI; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import brooklyn.config.ConfigKey; -import brooklyn.util.collections.Jsonya; - -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; - -public abstract class ConfigSummary implements HasName, Serializable { - - private static final long serialVersionUID = -2831796487073496730L; - - private final String name; - private final String type; - @JsonSerialize(include = Inclusion.NON_NULL) - private final Object defaultValue; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String description; - @JsonSerialize - private final boolean reconfigurable; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String label; - @JsonSerialize(include = Inclusion.NON_NULL) - private final Double priority; - @JsonSerialize(include = Inclusion.NON_NULL) - private final List<Map<String, String>> possibleValues; - - protected ConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("label") String label, - @JsonProperty("priority") Double priority, - @JsonProperty("possibleValues") List<Map<String, String>> possibleValues) { - this.name = name; - this.type = type; - this.description = description; - this.defaultValue = defaultValue; - this.reconfigurable = reconfigurable; - this.label = label; - this.priority = priority; - this.possibleValues = possibleValues; - } - - protected ConfigSummary(ConfigKey<?> config) { - this(config, null, null); - } - - @SuppressWarnings("rawtypes") - protected ConfigSummary(ConfigKey<?> config, String label, Double priority) { - this.name = config.getName(); - this.description = config.getDescription(); - this.reconfigurable = config.isReconfigurable(); - - /* Use String, to guarantee it is serializable; otherwise get: - * No serializer found for class brooklyn.policy.autoscaling.AutoScalerPolicy$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[9]->brooklyn.rest.domain.PolicyConfigSummary["defaultValue"]) - * at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52) - */ - this.label = label; - this.priority = priority; - if (config.getType().isEnum()) { - this.type = Enum.class.getName(); - this.defaultValue = (config.getDefaultValue() == null) ? null : ((Enum) config.getDefaultValue()).name(); - this.possibleValues = FluentIterable - .from(Arrays.asList((Enum[])(config.getType().getEnumConstants()))) - .transform(new Function<Enum, Map<String, String>>() { - @Nullable - @Override - public Map<String, String> apply(@Nullable Enum input) { - return ImmutableMap.of( - "value", input != null ? input.name() : null, - "description", input != null ? input.toString() : null); - }}) - .toList(); - } else { - this.type = config.getTypeName(); - this.defaultValue = Jsonya.convertToJsonPrimitive(config.getDefaultValue()); - this.possibleValues = null; - } - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - public boolean isReconfigurable() { - return reconfigurable; - } - - public Object getDefaultValue() { - // note constructor has converted to string, so this is safe for clients to use - return defaultValue; - } - - public String getLabel() { - return label; - } - - public Double getPriority() { - return priority; - } - - public List<Map<String, String>> getPossibleValues() { - return possibleValues; - } - - public abstract Map<String, URI> getLinks(); - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConfigSummary that = (ConfigSummary) o; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - return result; - } - - @Override - public abstract String toString(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java deleted file mode 100644 index d7a9c27..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import java.io.Serializable; -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -public class EffectorSummary implements HasName, Serializable { - - private static final long serialVersionUID = 8103535211378449509L; - - public static class ParameterSummary<T> implements HasName, Serializable { - private static final long serialVersionUID = -6393686096290306153L; - - private final String name; - private final String type; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String description; - private final T defaultValue; - - public ParameterSummary ( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") T defaultValue) { - this.name = name; - this.type = type; - this.description = description; - this.defaultValue = defaultValue; - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - public T getDefaultValue() { - return defaultValue; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ParameterSummary<?> that = (ParameterSummary<?>) o; - - return Objects.equal(this.name, that.name) - && Objects.equal(this.type, that.type) - && Objects.equal(this.description, that.description) - && Objects.equal(this.defaultValue, that.defaultValue); - } - - @Override - public int hashCode() { - return Objects.hashCode(name, type, description, defaultValue); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .omitNullValues() - .add("name", name) - .add("type", type) - .add("description", description) - .add("defaultValue", defaultValue) - .toString(); - } - } - - private final String name; - private final String returnType; - private final Set<ParameterSummary<?>> parameters; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String description; - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, URI> links; - - public EffectorSummary( - @JsonProperty("name") String name, - @JsonProperty("returnType") String returnType, - @JsonProperty("parameters") Set<ParameterSummary<?>> parameters, - @JsonProperty("description") String description, - @JsonProperty("links") Map<String, URI> links) { - this.name = name; - this.description = description; - this.returnType = returnType; - this.parameters = parameters; - this.links = links != null ? ImmutableMap.copyOf(links) : null; - } - - @Override - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public String getReturnType() { - return returnType; - } - - public Set<ParameterSummary<?>> getParameters() { - return parameters; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EffectorSummary that = (EffectorSummary) o; - - if (description != null ? !description.equals(that.description) : that.description != null) - return false; - if (links != null ? !links.equals(that.links) : that.links != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) - return false; - if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (returnType != null ? returnType.hashCode() : 0); - result = 31 * result + (parameters != null ? parameters.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "EffectorSummary{" - + "name='" + name + '\'' - + ", description='" + description + '\'' - + ", returnType='" + returnType + '\'' - + ", parameters=" + parameters - + ", links=" + links - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java deleted file mode 100644 index cadbf0a..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import brooklyn.config.ConfigKey; -import com.google.common.collect.ImmutableMap; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -public class EntityConfigSummary extends ConfigSummary { - - private static final long serialVersionUID = -1336134336883426030L; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, URI> links; - - public EntityConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("label") String label, - @JsonProperty("priority") Double priority, - @JsonProperty("possibleValues") List<Map<String, String>> possibleValues, - @JsonProperty("links") Map<String, URI> links) { - super(name, type, description, defaultValue, reconfigurable, label, priority, possibleValues); - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - public EntityConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) { - super(config, label, priority); - this.links = links != null ? ImmutableMap.copyOf(links) : null; - } - - @Override - public Map<String, URI> getLinks() { - return links; - } - - @Override - public String toString() { - return "EntityConfigSummary{" - + "name='" + getName() + '\'' - + ", type='" + getType() + '\'' - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java deleted file mode 100644 index 93c104b..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.rest.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.collect.ImmutableMap; - -import org.codehaus.jackson.annotate.JsonProperty; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; - -public class EntitySpec implements HasName, Serializable { - - private static final long serialVersionUID = -3882575609132757188L; - - private final String name; - private final String type; - private final Map<String, String> config; - - public EntitySpec(String type) { - this(null, type); - } - - public EntitySpec(String name, String type) { - this(name, type, Collections.<String, String> emptyMap()); - } - - public EntitySpec( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("config") Map<String, String> config) { - this.type = checkNotNull(type, "type"); - this.name = (name == null) ? type : name; - this.config = (config != null) ? ImmutableMap.copyOf(config) : ImmutableMap.<String, String> of(); - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public Map<String, String> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EntitySpec entitySpec = (EntitySpec) o; - - if (config != null ? !config.equals(entitySpec.config) : entitySpec.config != null) - return false; - if (name != null ? !name.equals(entitySpec.name) : entitySpec.name != null) - return false; - if (type != null ? !type.equals(entitySpec.type) : entitySpec.type != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (config != null ? config.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "EntitySpec{" - + "name='" + name + '\'' - + ", type='" + type + '\'' - + ", config=" + config - + '}'; - } -}
