http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java deleted file mode 100644 index 2ad5457..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java +++ /dev/null @@ -1,97 +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 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.io.Serializable; -import java.net.URI; -import java.util.Map; - -public class EntitySummary implements HasId, HasName, Serializable { - - private static final long serialVersionUID = 100490507982229165L; - - private final String id; - private final String name; - private final String type; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String catalogItemId; - private final Map<String, URI> links; - - public EntitySummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("catalogItemId") String catalogItemId, - @JsonProperty("links") Map<String, URI> links) { - this.type = type; - this.id = id; - this.name = name; - this.catalogItemId = catalogItemId; - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - public String getType() { - return type; - } - - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return name; - } - - public String getCatalogItemId() { - return catalogItemId; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - return (o instanceof EntitySummary) && id.equals(((EntitySummary) o).getId()); - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "EntitySummary{" - + "id='" + id + '\'' - + ", name=" + name - + ", type=" + type - + ", catalogItemId=" + catalogItemId - + ", links=" + links - + '}'; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/HasConfig.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasConfig.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/HasConfig.java deleted file mode 100644 index 14fbfa3..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasConfig.java +++ /dev/null @@ -1,28 +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.util.Map; - -/** Marker interface for summary objects with a name field */ -public interface HasConfig { - - public Map<String, ?> getConfig(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/HasId.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasId.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/HasId.java deleted file mode 100644 index 7879c47..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasId.java +++ /dev/null @@ -1,26 +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; - -/** Marker interface for summary objects with an id field */ -public interface HasId { - - public String getId(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/HasName.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasName.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/HasName.java deleted file mode 100644 index 511c249..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/HasName.java +++ /dev/null @@ -1,26 +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; - -/** Marker interface for summary objects with a name field */ -public interface HasName { - - public String getName(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java deleted file mode 100644 index 3d127c5..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java +++ /dev/null @@ -1,144 +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.base.Objects; -import com.google.common.collect.ImmutableMap; - -public class HighAvailabilitySummary implements Serializable { - - private static final long serialVersionUID = -317333127094471223L; - - public static class HaNodeSummary implements Serializable { - private static final long serialVersionUID = 9205960988226816539L; - - private final String nodeId; - private final URI nodeUri; - private final String status; - private final Long localTimestamp; - private final Long remoteTimestamp; - - public HaNodeSummary( - @JsonProperty("nodeId") String nodeId, - @JsonProperty("nodeUri") URI nodeUri, - @JsonProperty("status") String status, - @JsonProperty("localTimestamp") Long localTimestamp, - @JsonProperty("remoteTimestamp") Long remoteTimestamp) { - this.nodeId = nodeId; - this.nodeUri = nodeUri; - this.status = status; - this.localTimestamp = localTimestamp; - this.remoteTimestamp = remoteTimestamp; - } - - public String getNodeId() { - return nodeId; - } - - public URI getNodeUri() { - return nodeUri; - } - - public String getStatus() { - return status; - } - - public Long getLocalTimestamp() { - return localTimestamp; - } - - public Long getRemoteTimestamp() { - return remoteTimestamp; - } - - @Override - public boolean equals(Object o) { - return (o instanceof HaNodeSummary) && Objects.equal(nodeId, ((HaNodeSummary) o).getNodeId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(nodeId); - } - - @Override - public String toString() { - return "HighAvailabilitySummary{" - + "nodeId='" + nodeId + '\'' - + ", status='" + status + '\'' - + '}'; - } - } - - private final String ownId; - private final String masterId; - private final Map<String, HaNodeSummary> nodes; - private final Map<String, URI> links; - - public HighAvailabilitySummary( - @JsonProperty("ownId") String ownId, - @JsonProperty("masterId") String masterId, - @JsonProperty("nodes") Map<String, HaNodeSummary> nodes, - @JsonProperty("links") Map<String, URI> links) { - this.ownId = ownId; - this.masterId = masterId; - this.nodes = (nodes == null) ? ImmutableMap.<String, HaNodeSummary>of() : nodes; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - public String getOwnId() { - return ownId; - } - - public String getMasterId() { - return masterId; - } - - public Map<String, HaNodeSummary> getNodes() { - return nodes; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - return (o instanceof HighAvailabilitySummary) && ownId.equals(((HighAvailabilitySummary) o).getOwnId()); - } - - @Override - public int hashCode() { - return ownId != null ? ownId.hashCode() : 0; - } - - @Override - public String toString() { - return "HighAvailabilitySummary{" - + "ownId='" + ownId + '\'' - + ", links=" + links - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/LinkWithMetadata.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LinkWithMetadata.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LinkWithMetadata.java deleted file mode 100644 index 253da9a..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LinkWithMetadata.java +++ /dev/null @@ -1,88 +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.util.Map; - -import javax.annotation.Nullable; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.annotations.Beta; -import com.google.common.collect.ImmutableMap; - -@Beta -public class LinkWithMetadata implements Serializable { - - // TODO remove 'metadata' and promote its contents to be top-level fields; then unmark as Beta - - private static final long serialVersionUID = 3146368899471495143L; - - private final String link; - private final Map<String,Object> metadata; - - public LinkWithMetadata( - @JsonProperty("link") String link, - @Nullable @JsonProperty("metadata") Map<String,?> metadata) { - this.link = link; - this.metadata = (metadata == null) ? ImmutableMap.<String,Object>of() : ImmutableMap.<String,Object>copyOf(metadata); - } - - public String getLink() { - return link; - } - - public Map<String, Object> getMetadata() { - return metadata; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((link == null) ? 0 : link.hashCode()); - result = prime * result + ((metadata == null) ? 0 : metadata.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LinkWithMetadata other = (LinkWithMetadata) obj; - if (link == null) { - if (other.link != null) - return false; - } else if (!link.equals(other.link)) - return false; - if (metadata == null) { - if (other.metadata != null) - return false; - } else if (!metadata.equals(other.metadata)) - return false; - return true; - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationConfigSummary.java deleted file mode 100644 index b315459..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationConfigSummary.java +++ /dev/null @@ -1,62 +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.List; -import java.util.Map; - -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; - -public class LocationConfigSummary extends ConfigSummary { - - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, URI> links; - - public LocationConfigSummary( - @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); - } - - @Override - public Map<String, URI> getLinks() { - return links; - } - - @Override - public String toString() { - return "LocationConfigSummary{" - + "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/LocationSpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java deleted file mode 100644 index 862b34d..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java +++ /dev/null @@ -1,96 +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.util.Collections; -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 com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -// FIXME change name, due to confusion with brooklyn.location.LocationSpec <- no need, as we can kill the class instead soon! -/** @deprecated since 0.7.0 location spec objects will not be used from the client, instead pass yaml location spec strings */ -public class LocationSpec implements HasName, HasConfig, Serializable { - - private static final long serialVersionUID = -1562824224808185255L; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final String name; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String spec; - - @JsonSerialize(include = Inclusion.NON_EMPTY) - private final Map<String, ?> config; - - public static LocationSpec localhost() { - return new LocationSpec("localhost", "localhost", null); - } - - public LocationSpec( - @JsonProperty("name") String name, - @JsonProperty("spec") String spec, - @JsonProperty("config") @Nullable Map<String, ?> config) { - this.name = name; - this.spec = spec; - this.config = (config == null) ? Collections.<String, String> emptyMap() : ImmutableMap.copyOf(config); - } - - @Override - public String getName() { - return name; - } - - public String getSpec() { - return spec; - } - - public Map<String, ?> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LocationSpec that = (LocationSpec) o; - return Objects.equal(name, that.name) && Objects.equal(spec, that.spec) && Objects.equal(config, that.config); - } - - @Override - public int hashCode() { - return Objects.hashCode(spec, name, config); - } - - @Override - public String toString() { - return "LocationSpec{" - + "name='" + name + '\'' - + "spec='" + spec + '\'' - + ", config=" + config - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java deleted file mode 100644 index f975211..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java +++ /dev/null @@ -1,96 +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.net.URI; -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 com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -public class LocationSummary extends LocationSpec implements HasName, HasId { - - private static final long serialVersionUID = -4559153719273573670L; - - private final String id; - - /** only intended for instantiated Locations, not definitions */ - @JsonSerialize(include = Inclusion.NON_NULL) - private final String type; - private final Map<String, URI> links; - - public LocationSummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("spec") String spec, - @JsonProperty("type") String type, - @JsonProperty("config") @Nullable Map<String, ?> config, - @JsonProperty("links") Map<String, URI> links) { - super(name, spec, config); - this.id = checkNotNull(id); - this.type = type; - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - @Override - public String getId() { - return id; - } - - public String getType() { - return type; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - LocationSummary that = (LocationSummary) o; - return Objects.equal(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hashCode(id, links); - } - - @Override - public String toString() { - return "LocationSummary{" - + "id='" + getId() + '\'' - + "name='" + getName() + '\'' - + "spec='" + getSpec() + '\'' - + "type='" + getType() + '\'' - + ", config=" + getConfig() - + ", links=" + links - + '}'; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java deleted file mode 100644 index b59ebea..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java +++ /dev/null @@ -1,60 +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 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; - -public class PolicyConfigSummary extends ConfigSummary { - - private static final long serialVersionUID = 4339330833863794513L; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, URI> links; - - public PolicyConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("links") Map<String, URI> links) { - super(name, type, description, defaultValue, reconfigurable, null, null, null); - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - @Override - public Map<String, URI> getLinks() { - return links; - } - - @Override - public String toString() { - return "PolicyConfigSummary{" - + "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/PolicySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java deleted file mode 100644 index 8398a4d..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java +++ /dev/null @@ -1,108 +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 org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.collect.ImmutableMap; - -public class PolicySummary implements HasName, HasId, Serializable { - - private static final long serialVersionUID = -5086680835225136768L; - - private final String id; - private final String name; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String catalogItemId; - private final Status state; - private final Map<String, URI> links; - - public PolicySummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("catalogItemId") String catalogItemId, - @JsonProperty("state") Status state, - @JsonProperty("links") Map<String, URI> links) { - this.id = id; - this.name = name; - this.catalogItemId = catalogItemId; - this.state = state; - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return name; - } - - public String getCatalogItemId() { - return catalogItemId; - } - - public Status getState() { - return state; - } - - 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; - - PolicySummary that = (PolicySummary) o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - 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; - result = 31 * result + (id != null ? id.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ConfigSummary{" - + "name='" + name + '\'' - + ", id='" + id + '\'' - + ", catalogItemId='" + catalogItemId + '\'' - + ", links=" + links - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java deleted file mode 100644 index d7f0c03..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java +++ /dev/null @@ -1,67 +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 org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -public class ScriptExecutionSummary implements Serializable { - - private static final long serialVersionUID = -7707936602991185960L; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final Object result; - @JsonSerialize(include = Inclusion.NON_EMPTY) - private final String problem; - @JsonSerialize(include = Inclusion.NON_EMPTY) - private final String stdout; - @JsonSerialize(include = Inclusion.NON_EMPTY) - private final String stderr; - - public ScriptExecutionSummary( - @JsonProperty("result") Object result, - @JsonProperty("problem") String problem, - @JsonProperty("stdout") String stdout, - @JsonProperty("stderr") String stderr) { - super(); - this.result = result; - this.problem = problem; - this.stdout = stdout; - this.stderr = stderr; - } - - public Object getResult() { - return result; - } - - public String getProblem() { - return problem; - } - - public String getStderr() { - return stderr; - } - - public String getStdout() { - return stdout; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java deleted file mode 100644 index ad552ad..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java +++ /dev/null @@ -1,107 +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 org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import com.google.common.collect.ImmutableMap; - -public class SensorSummary implements HasName, Serializable { - - private static final long serialVersionUID = 1154308408351165426L; - - private final String name; - private final String type; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String description; - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, URI> links; - - public SensorSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("links") Map<String, URI> links) { - this.name = name; - this.type = type; - this.description = description; - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - 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; - - SensorSummary that = (SensorSummary) 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 (type != null ? !type.equals(that.type) : that.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 + (description != null ? description.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "SensorSummary{" - + "name='" + name + '\'' - + ", type='" + type + '\'' - + ", description='" + description + '\'' - + ", links=" + links - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/Status.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/Status.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/Status.java deleted file mode 100644 index d0f7baf..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/Status.java +++ /dev/null @@ -1,33 +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; - -/** - * @author Adam Lowe - */ -public enum Status { - ACCEPTED, - STARTING, - RUNNING, - STOPPING, - STOPPED, - DESTROYED, - ERROR, - UNKNOWN -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/SummaryComparators.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/SummaryComparators.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/SummaryComparators.java deleted file mode 100644 index e5f366d..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/SummaryComparators.java +++ /dev/null @@ -1,82 +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.util.Comparator; - -import javax.annotation.Nonnull; - -import brooklyn.basic.BrooklynObject; -import brooklyn.util.text.NaturalOrderComparator; -import brooklyn.util.text.Strings; - -/** - * Useful comparators for domain objects - */ -public class SummaryComparators { - - private SummaryComparators() {} - - private static NaturalOrderComparator COMPARATOR = new NaturalOrderComparator(); - - @Nonnull - static String getDisplayNameOrName(HasName o1) { - String n1 = null; - if (o1 instanceof BrooklynObject) - n1 = ((BrooklynObject)o1).getDisplayName(); - if (Strings.isEmpty(n1) && o1 instanceof HasConfig && ((HasConfig)o1).getConfig()!=null) - n1 = Strings.toString(((HasConfig)o1).getConfig().get("displayName")); - // prefer display name if set - if (Strings.isEmpty(n1)) - n1 = o1.getName(); - if (n1==null) { - // put last - return "~~~"; - } - return n1; - } - - public static Comparator<HasName> displayNameComparator() { - return new Comparator<HasName>() { - @Override - public int compare(HasName o1, HasName o2) { - return COMPARATOR.compare(getDisplayNameOrName(o1).toLowerCase(), getDisplayNameOrName(o2).toLowerCase()); - } - }; - } - - public static Comparator<HasName> nameComparator() { - return new Comparator<HasName>() { - @Override - public int compare(HasName o1, HasName o2) { - return COMPARATOR.compare(o1.getName(), o2.getName()); - } - }; - } - - public static Comparator<HasId> idComparator() { - return new Comparator<HasId>() { - @Override - public int compare(HasId o1, HasId o2) { - return o1.getId().compareTo(o2.getId()); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/TaskSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/TaskSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/TaskSummary.java deleted file mode 100644 index f6ffeaf..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/TaskSummary.java +++ /dev/null @@ -1,232 +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.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -import brooklyn.util.collections.Jsonya; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -public class TaskSummary implements HasId, Serializable { - - private static final long serialVersionUID = 4637850742127078158L; - - private final String id; - private final String displayName; - private final String entityId; - private final String entityDisplayName; - private final String description; - private final Collection<Object> tags; - - private final Long submitTimeUtc; - private final Long startTimeUtc; - private final Long endTimeUtc; - - private final String currentStatus; - private final Object result; - private final boolean isError; - private final boolean isCancelled; - - private final List<LinkWithMetadata> children; - private final LinkWithMetadata submittedByTask; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final LinkWithMetadata blockingTask; - @JsonSerialize(include = Inclusion.NON_NULL) - private final String blockingDetails; - - private final String detailedStatus; - - @JsonSerialize(include = Inclusion.NON_NULL) - private final Map<String, LinkWithMetadata> streams; - - private final Map<String, URI> links; - - public TaskSummary( - @JsonProperty("id") String id, - @JsonProperty("displayName") String displayName, - @JsonProperty("description") String description, - @JsonProperty("entityId") String entityId, - @JsonProperty("entityDisplayName") String entityDisplayName, - @JsonProperty("tags") Set<Object> tags, - @JsonProperty("submitTimeUtc") Long submitTimeUtc, - @JsonProperty("startTimeUtc") Long startTimeUtc, - @JsonProperty("endTimeUtc") Long endTimeUtc, - @JsonProperty("currentStatus") String currentStatus, - @JsonProperty("result") Object result, - @JsonProperty("isError") boolean isError, - @JsonProperty("isCancelled") boolean isCancelled, - @JsonProperty("children") List<LinkWithMetadata> children, - @JsonProperty("submittedByTask") LinkWithMetadata submittedByTask, - @JsonProperty("blockingTask") LinkWithMetadata blockingTask, - @JsonProperty("blockingDetails") String blockingDetails, - @JsonProperty("detailedStatus") String detailedStatus, - @JsonProperty("streams") Map<String, LinkWithMetadata> streams, - @JsonProperty("links") Map<String, URI> links) { - this.id = id; - this.displayName = displayName; - this.description = description; - this.entityId = entityId; - this.entityDisplayName = entityDisplayName; - this.tags = (tags == null) ? ImmutableList.of() : ImmutableList.<Object> copyOf(tags); - this.submitTimeUtc = submitTimeUtc; - this.startTimeUtc = startTimeUtc; - this.endTimeUtc = endTimeUtc; - this.currentStatus = currentStatus; - this.result = result; - this.isError = isError; - this.isCancelled = isCancelled; - this.children = children; - this.blockingDetails = blockingDetails; - this.blockingTask = blockingTask; - this.submittedByTask = submittedByTask; - this.detailedStatus = detailedStatus; - this.streams = streams; - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - @Override - public String getId() { - return id; - } - - public String getDisplayName() { - return displayName; - } - - public String getDescription() { - return description; - } - - public String getEntityId() { - return entityId; - } - - public String getEntityDisplayName() { - return entityDisplayName; - } - - public Collection<Object> getTags() { - List<Object> result = new ArrayList<Object>(); - for (Object t : tags) { - // TODO if we had access to a mapper we could use it to give better json - result.add(Jsonya.convertToJsonPrimitive(t)); - } - return result; - } - - @JsonIgnore - public Collection<Object> getRawTags() { - return tags; - } - - public Long getSubmitTimeUtc() { - return submitTimeUtc; - } - - public Long getStartTimeUtc() { - return startTimeUtc; - } - - public Long getEndTimeUtc() { - return endTimeUtc; - } - - public String getCurrentStatus() { - return currentStatus; - } - - public Object getResult() { - return result; - } - - /** @deprecated since 0.7.0 use {@link #isError} instead. */ - @Deprecated - @JsonIgnore - public boolean getIsError() { - return isError; - } - - /** @deprecated since 0.7.0 use {@link #isCancelled} instead. */ - @Deprecated - @JsonIgnore - public boolean getIsCancelled() { - return isCancelled; - } - - public boolean isError() { - return isError; - } - - public boolean isCancelled() { - return isCancelled; - } - - public List<LinkWithMetadata> getChildren() { - return children; - } - - public LinkWithMetadata getSubmittedByTask() { - return submittedByTask; - } - - public LinkWithMetadata getBlockingTask() { - return blockingTask; - } - - public String getBlockingDetails() { - return blockingDetails; - } - - public String getDetailedStatus() { - return detailedStatus; - } - - public Map<String, LinkWithMetadata> getStreams() { - return streams; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public String toString() { - return "TaskSummary{" - + "id='" + id + '\'' - + ", displayName='" + displayName + '\'' - + ", currentStatus='" + currentStatus + '\'' - + ", startTimeUtc='" + startTimeUtc + '\'' - + ", endTimeUtc='" + endTimeUtc + '\'' - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistic.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistic.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistic.java deleted file mode 100644 index 08425db..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistic.java +++ /dev/null @@ -1,124 +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 org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; - -import java.io.Serializable; -import java.net.URI; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author Adam Lowe - */ -public class UsageStatistic implements HasId, Serializable { - - private static final long serialVersionUID = 5701414937003064442L; - - private final Status status; - private final String id; - private final String applicationId; - private final String start; - private final String end; - private final long duration; - private final Map<String,String> metadata; - - public UsageStatistic( - @JsonProperty("status") Status status, - @JsonProperty("id") String id, - @JsonProperty("applicationId") String applicationId, - @JsonProperty("start") String start, - @JsonProperty("end") String end, - @JsonProperty("duration") long duration, - @JsonProperty("metadata") Map<String, String> metadata) { - this.status = checkNotNull(status, "status"); - this.id = checkNotNull(id, "id"); - this.applicationId = applicationId; - this.start = start; - this.end = end; - this.duration = duration; - this.metadata = (metadata == null) ? ImmutableMap.<String, String>of() : metadata; - } - - public Status getStatus() { - return status; - } - - @Override - public String getId() { - return id; - } - - public String getApplicationId() { - return applicationId; - } - - public String getStart() { - return start; - } - - public String getEnd() { - return end; - } - - public long getDuration() { - return duration; - } - - public Map<String, String> getMetadata() { - return metadata; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - UsageStatistic statistic = (UsageStatistic) o; - - return Objects.equal(status, statistic.status) && - Objects.equal(id, statistic.id) && - Objects.equal(applicationId, statistic.applicationId) && - Objects.equal(start, statistic.start) && - Objects.equal(end, statistic.end) && - Objects.equal(metadata, statistic.metadata); - } - - @Override - public int hashCode() { - return Objects.hashCode(status, id, applicationId, start, end, metadata); - } - - @Override - public String toString() { - return "UsageStatistic{" + - "status=" + status + - ", id='" + id + '\'' + - ", applicationId='" + applicationId + '\'' + - ", start='" + start + '\'' + - ", end='" + end + '\'' + - ", duration=" + duration + - ", metadata=" + metadata + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistics.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistics.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistics.java deleted file mode 100644 index fe985b1..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/UsageStatistics.java +++ /dev/null @@ -1,76 +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.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** - * @author Aled Sage - */ -public class UsageStatistics implements Serializable { - - private static final long serialVersionUID = -1842301852728290967L; - - // TODO populate links with /apps endpoint to link to /usage/applications/{id}, to make it more - // RESTy - - private final List<UsageStatistic> statistics; - private final Map<String, URI> links; - - public UsageStatistics(@JsonProperty("statistics") List<UsageStatistic> statistics, - @JsonProperty("links") Map<String, URI> links) { - this.statistics = statistics == null ? ImmutableList.<UsageStatistic> of() : ImmutableList.copyOf(statistics); - this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); - } - - public List<UsageStatistic> getStatistics() { - return statistics; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof UsageStatistics)) - return false; - UsageStatistics other = (UsageStatistics) o; - return Objects.equal(statistics, other.statistics); - } - - @Override - public int hashCode() { - return Objects.hashCode(statistics); - } - - @Override - public String toString() { - return "UsageStatistics{" + "statistics=" + statistics + ", links=" + links + '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/brooklyn/rest/domain/VersionSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/VersionSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/VersionSummary.java deleted file mode 100644 index 0127735..0000000 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/VersionSummary.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 static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class VersionSummary implements Serializable { - - private static final long serialVersionUID = 7275038546963638540L; - - private final String version; - private final String buildSha1; - private final String buildBranch; - private final List<BrooklynFeatureSummary> features; - - public VersionSummary(String version) { - this(version, null, null); - } - - public VersionSummary(String version, String buildSha1, String buildBranch) { - this(version, buildSha1, buildBranch, Collections.<BrooklynFeatureSummary>emptyList()); - } - - public VersionSummary( - @JsonProperty("version") String version, - @JsonProperty("buildSha1") String buildSha1, - @JsonProperty("buildBranch") String buildBranch, - @JsonProperty("features") List<BrooklynFeatureSummary> features) { - this.version = checkNotNull(version, "version"); - this.buildSha1 = buildSha1; - this.buildBranch = buildBranch; - this.features = checkNotNull(features, "features"); - } - - @Nonnull - public String getVersion() { - return version; - } - - @Nullable - public String getBuildSha1() { - return buildSha1; - } - - @Nullable - public String getBuildBranch() { - return buildBranch; - } - - @Nonnull - public List<BrooklynFeatureSummary> getFeatures() { - return features; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/AccessApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/AccessApi.java b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/AccessApi.java new file mode 100644 index 0000000..f5cd9ae --- /dev/null +++ b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/AccessApi.java @@ -0,0 +1,62 @@ +/* + * 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 org.apache.brooklyn.rest.api; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import brooklyn.rest.apidoc.Apidoc; +import org.apache.brooklyn.rest.domain.AccessSummary; + +import com.google.common.annotations.Beta; +import com.wordnik.swagger.core.ApiOperation; +import com.wordnik.swagger.core.ApiParam; + +@Beta +@Path("/v1/access") +@Apidoc("Access Control") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface AccessApi { + + // TODO First access use-case is to disable location-provisioning (for Citrix's Cloud Portal Business Manager (CPBM)). + // We rely on location implementations calling `managementContext.getAccessController().canProvisionLocation(parent)`, + // which isn't ideal (because some impls might forget to do this). We can't just do it in the core management-context + // because things like JcloudsLocation will provision the VM and only then create the JcloudsSshMachineLocation. + + @GET + @ApiOperation( + value = "Fetch access control summary", + responseClass = "org.apache.brooklyn.rest.domain.AccessSummary" + ) + public AccessSummary get(); + + @POST + @Path("/locationProvisioningAllowed") + @ApiOperation(value = "Sets whether location provisioning is permitted (beta feature)") + public Response locationProvisioningAllowed( + @ApiParam(name = "allowed", value = "Whether allowed or not", required = true) + @QueryParam("allowed") boolean allowed); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java new file mode 100644 index 0000000..4ba7e0f --- /dev/null +++ b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java @@ -0,0 +1,69 @@ +/* + * 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 org.apache.brooklyn.rest.api; + +import java.util.List; + +import brooklyn.rest.apidoc.Apidoc; +import org.apache.brooklyn.rest.domain.TaskSummary; + +import com.wordnik.swagger.core.ApiError; +import com.wordnik.swagger.core.ApiErrors; +import com.wordnik.swagger.core.ApiOperation; +import com.wordnik.swagger.core.ApiParam; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +@Path("/v1/activities") +@Apidoc("Activities") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface ActivityApi { + + @GET + @Path("/{task}") + @ApiOperation(value = "Fetch task details", responseClass = "org.apache.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); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c98f111/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java new file mode 100644 index 0000000..a05f5f1 --- /dev/null +++ b/usage/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java @@ -0,0 +1,222 @@ +/* + * 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 org.apache.brooklyn.rest.api; + +import java.util.List; +import java.util.Map; + +import javax.validation.Valid; +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 javax.ws.rs.core.Response; + +import org.codehaus.jackson.JsonNode; + +import brooklyn.rest.apidoc.Apidoc; +import org.apache.brooklyn.rest.domain.ApplicationSpec; +import org.apache.brooklyn.rest.domain.ApplicationSummary; +import org.apache.brooklyn.rest.domain.EntitySummary; + +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") +@Apidoc("Applications") +@Produces(MediaType.APPLICATION_JSON) +@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 = "org.apache.brooklyn.rest.domain.ApplicationSummary" + ) + public List<ApplicationSummary> list( + @ApiParam(value = "Regular expression to filter by", required = false) + @DefaultValue(".*") + @QueryParam("typeRegex") String typeRegex); + + // would be nice to have this on the API so default type regex not needed, but + // not yet implemented, as per: https://issues.jboss.org/browse/RESTEASY-798 + // (this method was added to this class, but it breaks the rest client) +// /** As {@link #list(String)}, filtering for <code>.*</code>. */ +// public List<ApplicationSummary> list(); + + @GET + @Path("/{application}") + @ApiOperation( + value = "Fetch a specific application", + responseClass = "org.apache.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 = "org.apache.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 = "org.apache.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 = "org.apache.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 = "org.apache.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 = "org.apache.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 = "org.apache.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); + +}
