mirror of https://github.com/apache/jclouds.git
Merge pull request #220 from jsonking/695-Terremark
Issue 695: terremark cpu and memory resource usage calls
This commit is contained in:
commit
4b56039f3c
|
@ -23,6 +23,7 @@ import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
|||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.CpuComputeResourceSummary;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* ComputePoolResourceSummaryList is more than a simple wrapper as it extends Resource.
|
||||
* <xs:complexType name="ComputePoolResourceSummaryList">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolResourceSummaryList")
|
||||
public class ComputePoolResourceSummaryList extends Resource<ComputePoolResourceSummaryList> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromSummaryList(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolResourceSummaryList> {
|
||||
private Set<ComputePoolResourceSummary> summaries = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList#getComputePoolResourceSummaries
|
||||
*/
|
||||
public Builder summaries(Set<ComputePoolResourceSummary> summaries) {
|
||||
this.summaries =(checkNotNull(summaries,"summaries"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolResourceSummaryList build() {
|
||||
return new ComputePoolResourceSummaryList(href, type, name, links, actions, summaries);
|
||||
}
|
||||
|
||||
public Builder fromSummaryList(ComputePoolResourceSummaryList in) {
|
||||
return fromResource(in).summaries(in.getComputePoolResourceSummaries());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolResourceSummaryList> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolResourceSummaryList> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "ComputePoolResourceSummary")
|
||||
private Set<ComputePoolResourceSummary> summaries = Sets.newLinkedHashSet();
|
||||
|
||||
private ComputePoolResourceSummaryList(URI href, String type, String name, Set<Link> links, Set<Action> actions, Set<ComputePoolResourceSummary> summaries) {
|
||||
super(href, type, name, links, actions);
|
||||
this.summaries = checkNotNull(summaries,"summaries");
|
||||
}
|
||||
|
||||
private ComputePoolResourceSummaryList() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Set<ComputePoolResourceSummary> getComputePoolResourceSummaries() {
|
||||
return summaries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolResourceSummaryList that = (ComputePoolResourceSummaryList) o;
|
||||
|
||||
if (!summaries.equals(that.summaries)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + summaries.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", summaries="+summaries;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* ComputePoolCpuUsage is more than a simple wrapper as it extends Resource.
|
||||
* <xs:complexType name="ComputePoolCpuUsage">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolCpuUsage")
|
||||
public class ComputePoolCpuUsage extends Resource<ComputePoolCpuUsage> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolCpuUsage(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolCpuUsage> {
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private CpuUsageDetails details;
|
||||
|
||||
/**
|
||||
* @see ComputePoolCpuUsage#getStartTime
|
||||
*/
|
||||
public Builder startTime(Date startTime) {
|
||||
this.startTime =(checkNotNull(startTime,"startTime"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolCpuUsage#getEndTime
|
||||
*/
|
||||
public Builder endTime(Date endTime) {
|
||||
this.endTime =(checkNotNull(endTime,"endTime"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolCpuUsage#getDetails
|
||||
*/
|
||||
public Builder details(CpuUsageDetails details) {
|
||||
this.details =(checkNotNull(details,"details"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolCpuUsage build() {
|
||||
return new ComputePoolCpuUsage(href, type, name, links, actions, startTime, endTime, details);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolCpuUsage(ComputePoolCpuUsage in) {
|
||||
return fromResource(in).startTime(in.getStartTime()).endTime(in.getEndTime()).details(in.getDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolCpuUsage> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolCpuUsage> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "StartTime", required = true)
|
||||
private Date startTime;
|
||||
|
||||
@XmlElement(name = "EndTime", required = true)
|
||||
private Date endTime;
|
||||
|
||||
@XmlElement(name = "CpuUsageDetailSummary", required = false)
|
||||
private CpuUsageDetails details;
|
||||
|
||||
private ComputePoolCpuUsage(URI href, String type, String name, Set<Link> links, Set<Action> actions, Date startTime, Date endTime, @Nullable CpuUsageDetails details) {
|
||||
super(href, type, name, links, actions);
|
||||
this.startTime = checkNotNull(startTime, "startTime");
|
||||
this.endTime = checkNotNull(endTime, "endTime");
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
private ComputePoolCpuUsage() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public CpuUsageDetails getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolCpuUsage that = (ComputePoolCpuUsage) o;
|
||||
|
||||
if (details != null ? !details.equals(that.details) : that.details != null)
|
||||
return false;
|
||||
if (!endTime.equals(that.endTime)) return false;
|
||||
if (!startTime.equals(that.startTime)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + startTime.hashCode();
|
||||
result = 31 * result + endTime.hashCode();
|
||||
result = 31 * result + (details != null ? details.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", startTime="+startTime+", endTime="+endTime+", details="+details;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* ComputePoolCpuUsageDetail is more than a simple wrapper as it extends Resource.
|
||||
* <xs:complexType name="ComputePoolCpuUsageDetail">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolCpuUsageDetail")
|
||||
public class ComputePoolCpuUsageDetail extends Resource<ComputePoolCpuUsageDetail> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolCpuUsage(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolCpuUsageDetail> {
|
||||
private Date time;
|
||||
private ResourceCapacity value;
|
||||
private VirtualMachinesCpuUsage virtualMachinesCpuUsage;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail#getTime
|
||||
*/
|
||||
public Builder time(Date time) {
|
||||
this.time =(checkNotNull(time,"time"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail#getValue
|
||||
*/
|
||||
public Builder value(ResourceCapacity value) {
|
||||
this.value =(checkNotNull(value,"value"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail#getVirtualMachinesCpuUsage
|
||||
*/
|
||||
public Builder virtualMachines(VirtualMachinesCpuUsage virtualMachinesCpuUsage) {
|
||||
this.virtualMachinesCpuUsage =(checkNotNull(virtualMachinesCpuUsage,"virtualMachinesCpuUsage"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolCpuUsageDetail build() {
|
||||
return new ComputePoolCpuUsageDetail(href, type, name, links, actions, time, value, virtualMachinesCpuUsage);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolCpuUsage(ComputePoolCpuUsageDetail in) {
|
||||
return fromResource(in).time(in.getTime()).value(in.getValue()).virtualMachines(in.getVirtualMachinesCpuUsage());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolCpuUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolCpuUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Time", required = true)
|
||||
private Date time;
|
||||
|
||||
@XmlElement(name = "Value", required = false)
|
||||
private ResourceCapacity value;
|
||||
|
||||
@XmlElement(name = "VirtualMachines", required = false)
|
||||
private VirtualMachinesCpuUsage virtualMachinesCpuUsage;
|
||||
|
||||
private ComputePoolCpuUsageDetail(URI href, String type, String name, Set<Link> links, Set<Action> actions, Date time, @Nullable ResourceCapacity value, @Nullable VirtualMachinesCpuUsage virtualMachinesCpuUsage) {
|
||||
super(href, type, name, links, actions);
|
||||
this.time = checkNotNull(time, "time");
|
||||
this.value = value;
|
||||
this.virtualMachinesCpuUsage = virtualMachinesCpuUsage;
|
||||
}
|
||||
|
||||
private ComputePoolCpuUsageDetail() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public ResourceCapacity getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public VirtualMachinesCpuUsage getVirtualMachinesCpuUsage() {
|
||||
return virtualMachinesCpuUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolCpuUsageDetail that = (ComputePoolCpuUsageDetail) o;
|
||||
|
||||
if (!time.equals(that.time)) return false;
|
||||
if (value != null ? !value.equals(that.value) : that.value != null)
|
||||
return false;
|
||||
if (virtualMachinesCpuUsage != null ? !virtualMachinesCpuUsage.equals(that.virtualMachinesCpuUsage) : that.virtualMachinesCpuUsage != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + time.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
result = 31 * result + (virtualMachinesCpuUsage != null ? virtualMachinesCpuUsage.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", time="+ time +", value="+value+", virtualMachinesCpuUsage="+ virtualMachinesCpuUsage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="ComputePoolCpuUsageDetailSummaryEntry">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class ComputePoolCpuUsageDetailSummaryEntry {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Builder toBuilder() {
|
||||
return new Builder().ComputePoolCpuUsageDetailSummaryEntry(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Date time;
|
||||
private ResourceCapacity value;
|
||||
|
||||
/**
|
||||
* @see ComputePoolCpuUsageDetailSummaryEntry#getTime
|
||||
*/
|
||||
public Builder time(Date time) {
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolCpuUsageDetailSummaryEntry#getValue
|
||||
*/
|
||||
public Builder value(ResourceCapacity value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComputePoolCpuUsageDetailSummaryEntry build() {
|
||||
return new ComputePoolCpuUsageDetailSummaryEntry(time,value);
|
||||
}
|
||||
|
||||
public Builder ComputePoolCpuUsageDetailSummaryEntry(ComputePoolCpuUsageDetailSummaryEntry in) {
|
||||
return time(in.getTime()).value(in.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Time", required = true)
|
||||
private Date time;
|
||||
|
||||
@XmlElement(name = "Value", required = false)
|
||||
private ResourceCapacity value;
|
||||
|
||||
|
||||
private ComputePoolCpuUsageDetailSummaryEntry(Date time,@Nullable ResourceCapacity value) {
|
||||
this.time = checkNotNull(time, "time");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private ComputePoolCpuUsageDetailSummaryEntry() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public ResourceCapacity getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ComputePoolCpuUsageDetailSummaryEntry that = (ComputePoolCpuUsageDetailSummaryEntry) o;
|
||||
|
||||
if (!time.equals(that.time)) return false;
|
||||
if (value != null ? !value.equals(that.value) : that.value != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = time.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[time="+ time +", value="+value+"]";
|
||||
}
|
||||
|
||||
}
|
|
@ -16,10 +16,11 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.resource;
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputeResourceSummary;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual ComputePoolCpuUsageDetailSummaryEntry elements.
|
||||
* <xs:complexType name="CpuUsageDetails">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class CpuUsageDetails {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromCpuUsageDetails(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<ComputePoolCpuUsageDetailSummaryEntry> entries = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see CpuUsageDetails#getEntries
|
||||
*/
|
||||
public Builder entries(Set<ComputePoolCpuUsageDetailSummaryEntry> entries) {
|
||||
this.entries = Sets.newLinkedHashSet(checkNotNull(entries, "entries"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addEntry(ComputePoolCpuUsageDetailSummaryEntry entry) {
|
||||
entries.add(checkNotNull(entry,"entry"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CpuUsageDetails build() {
|
||||
return new CpuUsageDetails(entries);
|
||||
}
|
||||
|
||||
public Builder fromCpuUsageDetails(CpuUsageDetails in) {
|
||||
return entries(in.getEntries());
|
||||
}
|
||||
}
|
||||
|
||||
private CpuUsageDetails() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private CpuUsageDetails(Set<ComputePoolCpuUsageDetailSummaryEntry> entries) {
|
||||
this.entries = Sets.newLinkedHashSet(entries);
|
||||
}
|
||||
|
||||
@XmlElement(name = "CpuUsageDetail", required=false)
|
||||
private Set<ComputePoolCpuUsageDetailSummaryEntry> entries = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<ComputePoolCpuUsageDetailSummaryEntry> getEntries() {
|
||||
return Collections.unmodifiableSet(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CpuUsageDetails tasks1 = (CpuUsageDetails) o;
|
||||
|
||||
if (!entries.equals(tasks1.entries)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return entries.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ entries.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="VirtualMachineCpuUsageDetail">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class VirtualMachineCpuUsageDetail extends BaseNamedResource<VirtualMachineCpuUsageDetail> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromVirtualMachineCpuUsageDetai(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<VirtualMachineCpuUsageDetail> {
|
||||
private ResourceCapacity usage;
|
||||
private int utilization;
|
||||
private boolean deleted;
|
||||
|
||||
/**
|
||||
* @see VirtualMachineCpuUsageDetail#getUsage
|
||||
*/
|
||||
public Builder usage(ResourceCapacity usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachineCpuUsageDetail#getUtilization
|
||||
*/
|
||||
public Builder utilization(int utilization) {
|
||||
this.utilization = utilization;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachineCpuUsageDetail#isDeleted
|
||||
*/
|
||||
public Builder deleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachineCpuUsageDetail build() {
|
||||
return new VirtualMachineCpuUsageDetail(href, type, name, usage, utilization, deleted);
|
||||
}
|
||||
|
||||
public Builder fromVirtualMachineCpuUsageDetai(VirtualMachineCpuUsageDetail in) {
|
||||
return fromNamedResource(in).usage(in.getUsage());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<VirtualMachineCpuUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<VirtualMachineCpuUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Usage", required = false)
|
||||
private ResourceCapacity usage;
|
||||
|
||||
@XmlElement(name = "Utilization", required = true)
|
||||
private int utilization;
|
||||
|
||||
@XmlElement(name = "Deleted", required = false)
|
||||
private boolean deleted;
|
||||
|
||||
private VirtualMachineCpuUsageDetail(URI href, String type, String name,
|
||||
@Nullable ResourceCapacity usage, int utilization, boolean deleted) {
|
||||
super(href, type, name);
|
||||
this.usage = usage;
|
||||
this.utilization = utilization;
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
private VirtualMachineCpuUsageDetail() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public ResourceCapacity getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public int getUtilization() {
|
||||
return utilization;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
VirtualMachineCpuUsageDetail that = (VirtualMachineCpuUsageDetail) o;
|
||||
|
||||
if (deleted != that.deleted) return false;
|
||||
if (utilization != that.utilization) return false;
|
||||
if (usage != null ? !usage.equals(that.usage) : that.usage != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (usage != null ? usage.hashCode() : 0);
|
||||
result = 31 * result + utilization;
|
||||
result = 31 * result + (deleted ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", usage="+usage+", utilization="+utilization+", deleted="+deleted;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.cpu;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual VirtualMachineCpuUsageDetail elements.
|
||||
* <xs:complexType name="CpuUsage_VirtualMachines">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class VirtualMachinesCpuUsage {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromCpuUsageDetails(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<VirtualMachineCpuUsageDetail> virtualMachinesCpuUsageDetail = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see VirtualMachinesCpuUsage#getVirtualMachinesCpuUsageDetail
|
||||
*/
|
||||
public Builder vmCpuUsageDetails(Set<VirtualMachineCpuUsageDetail> vmCpuUsageDetails) {
|
||||
this.virtualMachinesCpuUsageDetail = Sets.newLinkedHashSet(checkNotNull(vmCpuUsageDetails, "vmCpuUsageDetails"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addVmCpuUsageDetail(VirtualMachineCpuUsageDetail vmCpuUsageDetail) {
|
||||
virtualMachinesCpuUsageDetail.add(checkNotNull(vmCpuUsageDetail,"vmCpuUsageDetail"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VirtualMachinesCpuUsage build() {
|
||||
return new VirtualMachinesCpuUsage(virtualMachinesCpuUsageDetail);
|
||||
}
|
||||
|
||||
public Builder fromCpuUsageDetails(VirtualMachinesCpuUsage in) {
|
||||
return vmCpuUsageDetails(in.getVirtualMachinesCpuUsageDetail());
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualMachinesCpuUsage() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private VirtualMachinesCpuUsage(Set<VirtualMachineCpuUsageDetail> virtualMachinesCpuUsageDetail) {
|
||||
this.virtualMachinesCpuUsageDetail = Sets.newLinkedHashSet(virtualMachinesCpuUsageDetail);
|
||||
}
|
||||
|
||||
@XmlElement(name = "VirtualMachine", required=false)
|
||||
private Set<VirtualMachineCpuUsageDetail> virtualMachinesCpuUsageDetail = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<VirtualMachineCpuUsageDetail> getVirtualMachinesCpuUsageDetail() {
|
||||
return Collections.unmodifiableSet(virtualMachinesCpuUsageDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
VirtualMachinesCpuUsage that = (VirtualMachinesCpuUsage) o;
|
||||
|
||||
if (virtualMachinesCpuUsageDetail != null ? !virtualMachinesCpuUsageDetail.equals(that.virtualMachinesCpuUsageDetail) : that.virtualMachinesCpuUsageDetail != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return virtualMachinesCpuUsageDetail != null ? virtualMachinesCpuUsageDetail.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ virtualMachinesCpuUsageDetail.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* ComputePoolMemoryUsage is more than a simple wrapper as it extends Resource.
|
||||
* <xs:complexType name="ComputePoolMemoryUsage">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolMemoryUsage")
|
||||
public class ComputePoolMemoryUsage extends Resource<ComputePoolMemoryUsage> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolCpuUsage(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolMemoryUsage> {
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private MemoryUsageDetails details;
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsage#getStartTime
|
||||
*/
|
||||
public Builder startTime(Date startTime) {
|
||||
this.startTime =(checkNotNull(startTime,"startTime"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsage#getEndTime
|
||||
*/
|
||||
public Builder endTime(Date endTime) {
|
||||
this.endTime =(checkNotNull(endTime,"endTime"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsage#getDetails
|
||||
*/
|
||||
public Builder details(MemoryUsageDetails details) {
|
||||
this.details =(checkNotNull(details,"details"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolMemoryUsage build() {
|
||||
return new ComputePoolMemoryUsage(href, type, name, links, actions, startTime, endTime, details);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolCpuUsage(ComputePoolMemoryUsage in) {
|
||||
return fromResource(in).startTime(in.getStartTime()).endTime(in.getEndTime()).details(in.getDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolMemoryUsage> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolMemoryUsage> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "StartTime", required = true)
|
||||
private Date startTime;
|
||||
|
||||
@XmlElement(name = "EndTime", required = true)
|
||||
private Date endTime;
|
||||
|
||||
@XmlElement(name = "MemoryUsageDetailSummary", required = false)
|
||||
private MemoryUsageDetails details;
|
||||
|
||||
private ComputePoolMemoryUsage(URI href, String type, String name, Set<Link> links, Set<Action> actions, Date startTime, Date endTime, @Nullable MemoryUsageDetails details) {
|
||||
super(href, type, name, links, actions);
|
||||
this.startTime = checkNotNull(startTime, "startTime");
|
||||
this.endTime = checkNotNull(endTime, "endTime");
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
private ComputePoolMemoryUsage() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public MemoryUsageDetails getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolMemoryUsage that = (ComputePoolMemoryUsage) o;
|
||||
|
||||
if (details != null ? !details.equals(that.details) : that.details != null)
|
||||
return false;
|
||||
if (!endTime.equals(that.endTime)) return false;
|
||||
if (!startTime.equals(that.startTime)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + startTime.hashCode();
|
||||
result = 31 * result + endTime.hashCode();
|
||||
result = 31 * result + (details != null ? details.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", startTime="+startTime+", endTime="+endTime+", details="+details;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* ComputePoolMemoryUsageDetail is more than a simple wrapper as it extends Resource.
|
||||
* <xs:complexType name="ComputePoolMemoryUsageDetail">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolMemoryUsageDetail")
|
||||
public class ComputePoolMemoryUsageDetail extends Resource<ComputePoolMemoryUsageDetail> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolMemoryUsage(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolMemoryUsageDetail> {
|
||||
private Date time;
|
||||
private ResourceCapacity value;
|
||||
private VirtualMachinesMemoryUsage virtualMachinesMemoryUsage;
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsageDetail#getTime
|
||||
*/
|
||||
public Builder time(Date time) {
|
||||
this.time =(checkNotNull(time,"time"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsageDetail#getValue
|
||||
*/
|
||||
public Builder value(ResourceCapacity value) {
|
||||
this.value =(checkNotNull(value,"value"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsageDetail#getVirtualMachinesMemoryUsage
|
||||
*/
|
||||
public Builder virtualMachines(VirtualMachinesMemoryUsage virtualMachinesMemoryUsage) {
|
||||
this.virtualMachinesMemoryUsage =(checkNotNull(virtualMachinesMemoryUsage,"virtualMachinesMemoryUsage"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolMemoryUsageDetail build() {
|
||||
return new ComputePoolMemoryUsageDetail(href, type, name, links, actions, time, value, virtualMachinesMemoryUsage);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolMemoryUsage(ComputePoolMemoryUsageDetail in) {
|
||||
return fromResource(in).time(in.getTime()).value(in.getValue()).virtualMachines(in.getVirtualMachinesMemoryUsage());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolMemoryUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolMemoryUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Time", required = true)
|
||||
private Date time;
|
||||
|
||||
@XmlElement(name = "Value", required = false)
|
||||
private ResourceCapacity value;
|
||||
|
||||
@XmlElement(name = "VirtualMachines", required = false)
|
||||
private VirtualMachinesMemoryUsage virtualMachinesMemoryUsage;
|
||||
|
||||
private ComputePoolMemoryUsageDetail(URI href, String type, String name, Set<Link> links, Set<Action> actions, Date time, @Nullable ResourceCapacity value, @Nullable VirtualMachinesMemoryUsage virtualMachinesMemoryUsage) {
|
||||
super(href, type, name, links, actions);
|
||||
this.time = checkNotNull(time, "time");
|
||||
this.value = value;
|
||||
this.virtualMachinesMemoryUsage = virtualMachinesMemoryUsage;
|
||||
}
|
||||
|
||||
private ComputePoolMemoryUsageDetail() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public ResourceCapacity getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public VirtualMachinesMemoryUsage getVirtualMachinesMemoryUsage() {
|
||||
return virtualMachinesMemoryUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolMemoryUsageDetail that = (ComputePoolMemoryUsageDetail) o;
|
||||
|
||||
if (!time.equals(that.time)) return false;
|
||||
if (value != null ? !value.equals(that.value) : that.value != null)
|
||||
return false;
|
||||
if (virtualMachinesMemoryUsage != null ? !virtualMachinesMemoryUsage.equals(that.virtualMachinesMemoryUsage) : that.virtualMachinesMemoryUsage != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + time.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
result = 31 * result + (virtualMachinesMemoryUsage != null ? virtualMachinesMemoryUsage.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", time="+ time +", value="+value+", virtualMachinesMemoryUsage="+ virtualMachinesMemoryUsage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="ComputePoolMemoryUsageDetailSummaryEntry">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class ComputePoolMemoryUsageDetailSummaryEntry {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Builder toBuilder() {
|
||||
return new Builder().ComputePoolCpuUsageDetailSummaryEntry(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Date time;
|
||||
private ResourceCapacity value;
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsageDetailSummaryEntry#getTime
|
||||
*/
|
||||
public Builder time(Date time) {
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComputePoolMemoryUsageDetailSummaryEntry#getValue
|
||||
*/
|
||||
public Builder value(ResourceCapacity value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComputePoolMemoryUsageDetailSummaryEntry build() {
|
||||
return new ComputePoolMemoryUsageDetailSummaryEntry(time,value);
|
||||
}
|
||||
|
||||
public Builder ComputePoolCpuUsageDetailSummaryEntry(ComputePoolMemoryUsageDetailSummaryEntry in) {
|
||||
return time(in.getTime()).value(in.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Time", required = true)
|
||||
private Date time;
|
||||
|
||||
@XmlElement(name = "Value", required = false)
|
||||
private ResourceCapacity value;
|
||||
|
||||
|
||||
private ComputePoolMemoryUsageDetailSummaryEntry(Date time, @Nullable ResourceCapacity value) {
|
||||
this.time = checkNotNull(time, "time");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private ComputePoolMemoryUsageDetailSummaryEntry() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public ResourceCapacity getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ComputePoolMemoryUsageDetailSummaryEntry that = (ComputePoolMemoryUsageDetailSummaryEntry) o;
|
||||
|
||||
if (!time.equals(that.time)) return false;
|
||||
if (value != null ? !value.equals(that.value) : that.value != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = time.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[time="+ time +", value="+value+"]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual ComputePoolMemoryUsageDetailSummaryEntry elements.
|
||||
* <xs:complexType name="MemoryUsageDetails">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class MemoryUsageDetails {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromMemoryUsageDetails(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<ComputePoolMemoryUsageDetailSummaryEntry> entries = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see MemoryUsageDetails#getEntries
|
||||
*/
|
||||
public Builder entries(Set<ComputePoolMemoryUsageDetailSummaryEntry> entries) {
|
||||
this.entries = Sets.newLinkedHashSet(checkNotNull(entries, "entries"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addEntry(ComputePoolMemoryUsageDetailSummaryEntry entry) {
|
||||
entries.add(checkNotNull(entry,"entry"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MemoryUsageDetails build() {
|
||||
return new MemoryUsageDetails(entries);
|
||||
}
|
||||
|
||||
public Builder fromMemoryUsageDetails(MemoryUsageDetails in) {
|
||||
return entries(in.getEntries());
|
||||
}
|
||||
}
|
||||
|
||||
private MemoryUsageDetails() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private MemoryUsageDetails(Set<ComputePoolMemoryUsageDetailSummaryEntry> entries) {
|
||||
this.entries = Sets.newLinkedHashSet(entries);
|
||||
}
|
||||
|
||||
@XmlElement(name = "MemoryUsageDetail", required=false)
|
||||
private Set<ComputePoolMemoryUsageDetailSummaryEntry> entries = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<ComputePoolMemoryUsageDetailSummaryEntry> getEntries() {
|
||||
return Collections.unmodifiableSet(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
MemoryUsageDetails tasks1 = (MemoryUsageDetails) o;
|
||||
|
||||
if (!entries.equals(tasks1.entries)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return entries.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ entries.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="VirtualMachineMemoryUsageDetail">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class VirtualMachineMemoryUsageDetail extends BaseNamedResource<VirtualMachineMemoryUsageDetail> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromVirtualMachineMemoryUsageDetail(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<VirtualMachineMemoryUsageDetail> {
|
||||
private ResourceCapacity usage;
|
||||
private int utilization;
|
||||
private boolean deleted;
|
||||
|
||||
/**
|
||||
* @see VirtualMachineMemoryUsageDetail#getUsage
|
||||
*/
|
||||
public Builder usage(ResourceCapacity usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachineMemoryUsageDetail#getUtilization
|
||||
*/
|
||||
public Builder utilization(int utilization) {
|
||||
this.utilization = utilization;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachineMemoryUsageDetail#isDeleted
|
||||
*/
|
||||
public Builder deleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachineMemoryUsageDetail build() {
|
||||
return new VirtualMachineMemoryUsageDetail(href, type, name, usage, utilization, deleted);
|
||||
}
|
||||
|
||||
public Builder fromVirtualMachineMemoryUsageDetail(VirtualMachineMemoryUsageDetail in) {
|
||||
return fromNamedResource(in).usage(in.getUsage());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<VirtualMachineMemoryUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<VirtualMachineMemoryUsageDetail> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Usage", required = false)
|
||||
private ResourceCapacity usage;
|
||||
|
||||
@XmlElement(name = "Utilization", required = true)
|
||||
private int utilization;
|
||||
|
||||
@XmlElement(name = "Deleted", required = false)
|
||||
private boolean deleted;
|
||||
|
||||
private VirtualMachineMemoryUsageDetail(URI href, String type, String name,
|
||||
@Nullable ResourceCapacity usage, int utilization, boolean deleted) {
|
||||
super(href, type, name);
|
||||
this.usage = usage;
|
||||
this.utilization = utilization;
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
private VirtualMachineMemoryUsageDetail() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public ResourceCapacity getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public int getUtilization() {
|
||||
return utilization;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
VirtualMachineMemoryUsageDetail that = (VirtualMachineMemoryUsageDetail) o;
|
||||
|
||||
if (deleted != that.deleted) return false;
|
||||
if (utilization != that.utilization) return false;
|
||||
if (usage != null ? !usage.equals(that.usage) : that.usage != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (usage != null ? usage.hashCode() : 0);
|
||||
result = 31 * result + utilization;
|
||||
result = 31 * result + (deleted ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", usage="+usage+", utilization="+utilization+", deleted="+deleted;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.domain.resource.memory;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual VirtualMachineMemoryUsageDetail elements.
|
||||
* <xs:complexType name="MemoryUsage_VirtualMachines">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class VirtualMachinesMemoryUsage {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromMemoryUsageDetails(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<VirtualMachineMemoryUsageDetail> virtualMachinesMemoryUsageDetail = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see VirtualMachinesMemoryUsage#getVirtualMachinesMemoryUsageDetail
|
||||
*/
|
||||
public Builder vmMemoryUsageDetails(Set<VirtualMachineMemoryUsageDetail> vmMemoryUsageDetails) {
|
||||
this.virtualMachinesMemoryUsageDetail = Sets.newLinkedHashSet(checkNotNull(vmMemoryUsageDetails, "vmMemoryUsageDetails"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addVmMemoryUsageDetail(VirtualMachineMemoryUsageDetail vmMemoryUsageDetail) {
|
||||
virtualMachinesMemoryUsageDetail.add(checkNotNull(vmMemoryUsageDetail,"vmMemoryUsageDetail"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VirtualMachinesMemoryUsage build() {
|
||||
return new VirtualMachinesMemoryUsage(virtualMachinesMemoryUsageDetail);
|
||||
}
|
||||
|
||||
public Builder fromMemoryUsageDetails(VirtualMachinesMemoryUsage in) {
|
||||
return vmMemoryUsageDetails(in.getVirtualMachinesMemoryUsageDetail());
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualMachinesMemoryUsage() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private VirtualMachinesMemoryUsage(Set<VirtualMachineMemoryUsageDetail> virtualMachinesMemoryUsageDetail) {
|
||||
this.virtualMachinesMemoryUsageDetail = Sets.newLinkedHashSet(virtualMachinesMemoryUsageDetail);
|
||||
}
|
||||
|
||||
@XmlElement(name = "VirtualMachine", required=false)
|
||||
private Set<VirtualMachineMemoryUsageDetail> virtualMachinesMemoryUsageDetail = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<VirtualMachineMemoryUsageDetail> getVirtualMachinesMemoryUsageDetail() {
|
||||
return Collections.unmodifiableSet(virtualMachinesMemoryUsageDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
VirtualMachinesMemoryUsage that = (VirtualMachinesMemoryUsage) o;
|
||||
|
||||
if (virtualMachinesMemoryUsageDetail != null ? !virtualMachinesMemoryUsageDetail.equals(that.virtualMachinesMemoryUsageDetail) : that.virtualMachinesMemoryUsageDetail != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return virtualMachinesMemoryUsageDetail != null ? virtualMachinesMemoryUsageDetail.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ virtualMachinesMemoryUsageDetail.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -153,10 +153,6 @@ public class Templates extends Resource<Templates> {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(links.getLinks());
|
||||
}
|
||||
|
||||
public Set<TemplateFamily> getTemplateFamilies() {
|
||||
return families.getTemplateFamilies();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,12 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.*;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsageDetail;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
|
@ -42,6 +47,15 @@ import java.net.URI;
|
|||
@Headers(keys = "x-tmrk-version", values = "{jclouds.api-version}")
|
||||
public interface ResourceAsyncClient {
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getResourceSummary
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolResourceSummary; type=collection")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolResourceSummaryList> getResourceSummaries(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getResourceSummary
|
||||
*/
|
||||
|
@ -50,4 +64,40 @@ public interface ResourceAsyncClient {
|
|||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolResourceSummary> getResourceSummary(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getComputePoolCpuUsage
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolCpuUsage")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolCpuUsage> getComputePoolCpuUsage(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getComputePoolCpuUsageDetail
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolCpuUsageDetail")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolCpuUsageDetail> getComputePoolCpuUsageDetail(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getComputePoolMemoryUsage
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolMemoryUsage")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolMemoryUsage> getComputePoolMemoryUsage(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getComputePoolMemoryUsageDetail
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolMemoryUsageDetail")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolMemoryUsageDetail> getComputePoolMemoryUsageDetail(@EndpointParam URI uri);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsageDetail;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -38,10 +43,92 @@ import java.util.concurrent.TimeUnit;
|
|||
public interface ResourceClient {
|
||||
|
||||
/**
|
||||
* The Get Resources Summary call returns resource summary information regarding a specified compute pool defined in an environment.
|
||||
* @param uri the uri of the compute pool
|
||||
* The Get Resources Summary List call returns summary information regarding
|
||||
* resource utilization in the compute pools defined in an environment.
|
||||
*
|
||||
* @param uri the uri of the call based upon the environment
|
||||
* e.g. /cloudapi/ecloud/computepools/environments/{id}/resourcesummarylist
|
||||
* @return the summary list
|
||||
*/
|
||||
ComputePoolResourceSummaryList getResourceSummaries(URI uri);
|
||||
|
||||
/**
|
||||
* The Get Resources Summary call returns resource summary information regarding
|
||||
* a specified compute pool defined in an environment.
|
||||
*
|
||||
* @param uri the uri of the call based upon the compute pool
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/resourcesummary
|
||||
* @return the summary
|
||||
*/
|
||||
ComputePoolResourceSummary getResourceSummary(URI uri);
|
||||
|
||||
/**
|
||||
* The call returns information regarding processor usage for a specified compute pool
|
||||
* defined in an environment at five minute intervals for the 24 hours ending one hour
|
||||
* prior to the current time, rounded later.
|
||||
* For example, if current time is 11:22, the end time is 10:25.
|
||||
*
|
||||
* @param uri the uri of the call based upon the compute pool
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/usage/cpu
|
||||
* @return The cpu usage for the compute pool
|
||||
*/
|
||||
ComputePoolCpuUsage getComputePoolCpuUsage(URI uri);
|
||||
|
||||
/**
|
||||
* The Get Resources Usage Processor Detail call returns information regarding processor usage
|
||||
* for a specified compute pool defined in an environment at the time in the URL query part,
|
||||
* a specified five minute time interval within the 24 hours ending one hour prior to
|
||||
* the current time, rounded later.
|
||||
* For example, if current time is 11:22, the end time is 10:25.
|
||||
* The response includes usage of every virtual machine during the interval.
|
||||
*
|
||||
* Note: The query part is required and the time passed as the parameter must
|
||||
* precisely match a time in the preceding 24 hours.
|
||||
*
|
||||
* Times are on five minute intervals starting on the hour.
|
||||
* Available times are in Time in the response to {@code getComputePoolCpuUsage}
|
||||
* The time parameter is of the form 2011-12-05t10%3a10%3a00z
|
||||
*
|
||||
* Deleted is applicable and appears only when virtual machines have been removed
|
||||
* subsequent to the time of the snapshot.
|
||||
*
|
||||
* @param uri the uri of the call based upon the compute pool and the time
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/usage/cpu/details?time={time}
|
||||
* @return the compute pool cpu usage detail
|
||||
*/
|
||||
ComputePoolCpuUsageDetail getComputePoolCpuUsageDetail(URI uri);
|
||||
|
||||
/**
|
||||
* The Get Resources Usage Memory call returns information regarding memory usage
|
||||
* for a specified compute pool defined in an environment at five minute intervals
|
||||
* for the 24 hours ending one hour prior to the current time, rounded later.
|
||||
* For example, if current time is 11:22, the end time 10:25.
|
||||
*
|
||||
* @param uri the uri of the call based upon the compute pool
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/usage/memory
|
||||
* @return The memory usage for the compute pool
|
||||
*/
|
||||
ComputePoolMemoryUsage getComputePoolMemoryUsage(URI uri);
|
||||
|
||||
/**
|
||||
* The Get Resources Usage Memory Detail call returns information regarding memory usage
|
||||
* for a specified compute pool defined in an environment at the time in the URL query part,
|
||||
* a specified five minute time interval within the 24 hours ending one hour prior to the current time,
|
||||
* rounded later.
|
||||
* For example, if current time is 11:22, the end time is 10:25.
|
||||
* The response includes usage of every virtual machine during the interval.
|
||||
*
|
||||
* Note: The query part is required and the time passed as the parameter must precisely match
|
||||
* a time in the preceding 24 hours.
|
||||
* Times are on five minute intervals starting on the hour.
|
||||
* Available times are in Time in the response to {@code getComputePoolMemoryUsage}.
|
||||
*
|
||||
* Deleted is applicable and appears only when virtual machine have been removed subsequent
|
||||
* to the time of the snapshot.
|
||||
*
|
||||
* @param uri the uri of the call based upon the compute pool and the time
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/usage/memory/details?time={time}
|
||||
* @return the compute pool memory usage detail
|
||||
*/
|
||||
ComputePoolMemoryUsageDetail getComputePoolMemoryUsageDetail(URI uri);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,21 @@ import java.net.URISyntaxException;
|
|||
@Test(groups = "unit", testName = "ResourceAsyncClient")
|
||||
public class ResourceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClientTest<ResourceAsyncClient> {
|
||||
|
||||
public void testGetResourceSummaries() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getResourceSummaries", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, new URI("/cloudapi/ecloud/computepools/environments/77/resourcesummarylist"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/environments/77/resourcesummarylist HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolResourceSummary; type=collection\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetResourceSummary() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getResourceSummary", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, new URI("/cloudapi/ecloud/computepools/89/resourcesummary"));
|
||||
|
@ -53,6 +68,66 @@ public class ResourceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncCl
|
|||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetComputePoolCpuUsage() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolCpuUsage", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/usage/cpu"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/usage/cpu HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolCpuUsage\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetComputePoolCpuUsageDetail() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolCpuUsageDetail", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/usage/cpu/details?time=2011-12-05t10%3a10%3a00z"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/usage/cpu/details?time=2011-12-05t10%3a10%3a00z HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolCpuUsageDetail\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetComputePoolMemoryUsage() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolMemoryUsage", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/usage/memory"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/usage/memory HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolMemoryUsage\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetComputePoolMemoryUsageDetail() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolMemoryUsageDetail", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/usage/memory/details?time=2011-12-05t10%3a10%3a00z"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/usage/memory/details?time=2011-12-05t10%3a10%3a00z HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolMemoryUsageDetail\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<ResourceAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<ResourceAsyncClient>>() {
|
||||
|
|
|
@ -18,12 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsageDetail;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -42,6 +50,15 @@ public class ResourceClientLiveTest extends BaseTerremarkEnterpriseCloudClientLi
|
|||
|
||||
private ResourceClient client;
|
||||
|
||||
public void testGetResourceSummaries() throws Exception {
|
||||
ComputePoolResourceSummaryList list = client.getResourceSummaries(URI.create("/cloudapi/ecloud/computepools/environments/77/resourcesummarylist"));
|
||||
assertNotNull(list);
|
||||
}
|
||||
|
||||
public void testMissingResourceSummaries() {
|
||||
assertNull(client.getResourceSummaries(URI.create("/cloudapi/ecloud/computepools/environments/-1/resourcesummarylist")));
|
||||
}
|
||||
|
||||
public void testGetResourceSummary() throws Exception {
|
||||
ComputePoolResourceSummary resourceSummary = client.getResourceSummary(URI.create("/cloudapi/ecloud/computepools/89/resourcesummary"));
|
||||
assertNotNull(resourceSummary);
|
||||
|
@ -50,4 +67,51 @@ public class ResourceClientLiveTest extends BaseTerremarkEnterpriseCloudClientLi
|
|||
public void testMissingResourceSummary() {
|
||||
assertNull(client.getResourceSummary(URI.create("/cloudapi/ecloud/computepools/-1/resourcesummary")));
|
||||
}
|
||||
|
||||
public void testGetComputePoolCpuUsage() throws Exception {
|
||||
ComputePoolCpuUsage usage = client.getComputePoolCpuUsage(URI.create("/cloudapi/ecloud/computepools/89/usage/cpu"));
|
||||
assertNotNull(usage);
|
||||
for(Link link: usage.getLinks()) {
|
||||
//The compute pool cpu usage has a link to a detail entry
|
||||
if( "application/vnd.tmrk.cloud.computePoolCpuUsageDetail".equals(link.getType())) {
|
||||
testGetComputePoolCpuUsageDetail(link.getHref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testMissingComputePoolCpuUsage() {
|
||||
assertNull(client.getComputePoolCpuUsage(URI.create("/cloudapi/ecloud/computepools/-1/usage/cpu")));
|
||||
}
|
||||
|
||||
private void testGetComputePoolCpuUsageDetail(URI uri) {
|
||||
ComputePoolCpuUsageDetail detail = client.getComputePoolCpuUsageDetail(uri);
|
||||
assertNotNull(detail.getTime());
|
||||
}
|
||||
|
||||
public void testMissingComputePoolCpuUsageDetail() {
|
||||
assertNull(client.getComputePoolCpuUsageDetail(URI.create("/cloudapi/ecloud/computepools/-1/usage/cpu/details?time=2011-12-05t10%3a10%3a00z")));
|
||||
}
|
||||
|
||||
public void testMissingDateComputePoolCpuUsageDetail() {
|
||||
ComputePoolCpuUsageDetail detail = client.getComputePoolCpuUsageDetail(URI.create("/cloudapi/ecloud/computepools/89/usage/cpu/details?time=1974-01-01t10%3a10%3a00z"));
|
||||
assertNotNull(detail.getTime());
|
||||
assertEquals(detail.getValue(), ResourceCapacity.builder().value(0).unit("MHz").build());
|
||||
assertNull(detail.getVirtualMachinesCpuUsage());
|
||||
}
|
||||
|
||||
public void testGetComputePoolMemoryUsage() throws Exception {
|
||||
ComputePoolMemoryUsage usage = client.getComputePoolMemoryUsage(URI.create("/cloudapi/ecloud/computepools/89/usage/memory"));
|
||||
assertNotNull(usage);
|
||||
for(Link link: usage.getLinks()) {
|
||||
//The compute pool memory usage has a link to a detail entry
|
||||
if( "application/vnd.tmrk.cloud.computePoolMemoryUsageDetail".equals(link.getType())) {
|
||||
testGetComputePoolMemoryUsageDetail(link.getHref());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testGetComputePoolMemoryUsageDetail(URI uri) {
|
||||
ComputePoolMemoryUsageDetail detail = client.getComputePoolMemoryUsageDetail(uri);
|
||||
assertNotNull(detail.getTime());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.VirtualMachineCpuUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolCpuUsageDetail
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolResourceSummaryListJAXBParsingTest")
|
||||
public class ComputePoolCpuUsageDetailJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
private SimpleDateFormatDateService dateService;
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
dateService = new SimpleDateFormatDateService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolCpuUsageDetail", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolCpuUsageDetail> parser = (Function<HttpResponse, ComputePoolCpuUsageDetail>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolCpuUsageDetail.xml");
|
||||
ComputePoolCpuUsageDetail detail = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(detail.getTime(), dateService.iso8601DateParse("2011-12-05T10:10:00.0Z"));
|
||||
assertEquals(detail.getValue(), ResourceCapacity.builder().value(43).unit("MHz").build());
|
||||
Set<VirtualMachineCpuUsageDetail> virtualMachinesCpuUsageDetail = detail.getVirtualMachinesCpuUsage().getVirtualMachinesCpuUsageDetail();
|
||||
assertDetail(virtualMachinesCpuUsageDetail);
|
||||
}
|
||||
|
||||
public void testParseNoDetailWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolCpuUsageDetail", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolCpuUsageDetail> parser = (Function<HttpResponse, ComputePoolCpuUsageDetail>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolCpuUsageDetailNoDetail.xml");
|
||||
ComputePoolCpuUsageDetail detail = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(detail.getTime(), dateService.iso8601DateParse("1974-12-05T10:10:00.0Z"));
|
||||
assertEquals(detail.getValue(), ResourceCapacity.builder().value(0).unit("MHz").build());
|
||||
assertNull(detail.getVirtualMachinesCpuUsage());
|
||||
}
|
||||
|
||||
private void assertDetail(Set<VirtualMachineCpuUsageDetail> details) {
|
||||
assertEquals(details.size(),1);
|
||||
VirtualMachineCpuUsageDetail detail = Iterables.getOnlyElement(details);
|
||||
VirtualMachineCpuUsageDetail expected = VirtualMachineCpuUsageDetail.builder()
|
||||
.href(URI.create("/cloudapi/ecloud/virtualmachines/5504"))
|
||||
.name("helloworld")
|
||||
.type("application/vnd.tmrk.cloud.virtualMachine")
|
||||
.usage(ResourceCapacity.builder().value(43).unit("MHz").build())
|
||||
.utilization(2)
|
||||
.build();
|
||||
assertEquals(detail,expected);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsageDetailSummaryEntry;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.CpuUsageDetails;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolCpuUsage
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolCpuUsageJAXBParsingTest")
|
||||
public class ComputePoolCpuUsageJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
private SimpleDateFormatDateService dateService;
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
dateService = new SimpleDateFormatDateService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolCpuUsage", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolCpuUsage> parser = (Function<HttpResponse, ComputePoolCpuUsage>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolCpuUsage.xml");
|
||||
ComputePoolCpuUsage cpuUsage = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(cpuUsage.getLinks());
|
||||
assertEquals(cpuUsage.getStartTime(), dateService.iso8601DateParse("2011-12-05T09:45:00.0Z"));
|
||||
assertEquals(cpuUsage.getEndTime(), dateService.iso8601DateParse("2011-12-06T09:45:00.0Z"));
|
||||
assertDetails(cpuUsage.getDetails());
|
||||
|
||||
Set<ComputePoolCpuUsageDetailSummaryEntry> entries = cpuUsage.getDetails().getEntries();
|
||||
ComputePoolCpuUsageDetailSummaryEntry first = Iterables.getFirst(entries, null);
|
||||
assertEquals(cpuUsage.getStartTime(),first.getTime());
|
||||
|
||||
ComputePoolCpuUsageDetailSummaryEntry last = Iterables.getLast(entries, null);
|
||||
assertEquals(cpuUsage.getEndTime(),last.getTime());
|
||||
}
|
||||
|
||||
private void assertLinks(Set<Link> links) {
|
||||
assertEquals(links.size(),2);
|
||||
Link link = Iterables.get(links, 0);
|
||||
assertEquals(link.getName(),"Default Compute Pool");
|
||||
assertEquals(link.getRelationship(), Link.Relationship.UP);
|
||||
|
||||
Link link2 = Iterables.get(links, 1);
|
||||
assertEquals(link2.getHref(), URI.create("/cloudapi/ecloud/computepools/89/usage/cpu/details?time=2011-12-05t09%3a45%3a00z"));
|
||||
assertEquals(link2.getType(), "application/vnd.tmrk.cloud.computePoolCpuUsageDetail");
|
||||
assertEquals(link2.getRelationship(), Link.Relationship.DOWN);
|
||||
}
|
||||
|
||||
private void assertDetails(CpuUsageDetails details) {
|
||||
assertEquals(details.getEntries().size(), 289);
|
||||
for(ComputePoolCpuUsageDetailSummaryEntry entry: details.getEntries()) {
|
||||
assertDetail(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertDetail(ComputePoolCpuUsageDetailSummaryEntry entry) {
|
||||
assertNotNull(entry.getTime());
|
||||
assertNotNull(entry.getValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.VirtualMachineMemoryUsageDetail;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolMemoryUsageDetail
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolResourceSummaryListJAXBParsingTest")
|
||||
public class ComputePoolMemoryUsageDetailJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
private SimpleDateFormatDateService dateService;
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
dateService = new SimpleDateFormatDateService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolMemoryUsageDetail", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolMemoryUsageDetail> parser = (Function<HttpResponse, ComputePoolMemoryUsageDetail>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolMemoryUsageDetail.xml");
|
||||
ComputePoolMemoryUsageDetail detail = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(detail.getTime(), dateService.iso8601DateParse("2011-12-05T15:55:00.0Z"));
|
||||
assertEquals(detail.getValue(), ResourceCapacity.builder().value(404).unit("MB").build());
|
||||
Set<VirtualMachineMemoryUsageDetail> virtualMachinesMemoryUsageDetail = detail.getVirtualMachinesMemoryUsage().getVirtualMachinesMemoryUsageDetail();
|
||||
assertDetail(virtualMachinesMemoryUsageDetail);
|
||||
}
|
||||
|
||||
public void testParseNoDetailWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolMemoryUsageDetail", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolMemoryUsageDetail> parser = (Function<HttpResponse, ComputePoolMemoryUsageDetail>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolMemoryUsageDetailNoDetail.xml");
|
||||
ComputePoolMemoryUsageDetail detail = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(detail.getTime(), dateService.iso8601DateParse("1974-12-05T15:55:00.0Z"));
|
||||
assertEquals(detail.getValue(), ResourceCapacity.builder().value(0).unit("MB").build());
|
||||
assertNull(detail.getVirtualMachinesMemoryUsage());
|
||||
}
|
||||
|
||||
private void assertDetail(Set<VirtualMachineMemoryUsageDetail> details) {
|
||||
assertEquals(details.size(),1);
|
||||
VirtualMachineMemoryUsageDetail detail = Iterables.getOnlyElement(details);
|
||||
VirtualMachineMemoryUsageDetail expected = VirtualMachineMemoryUsageDetail.builder()
|
||||
.href(URI.create("/cloudapi/ecloud/virtualmachines/5504"))
|
||||
.name("helloworld")
|
||||
.type("application/vnd.tmrk.cloud.virtualMachine")
|
||||
.usage(ResourceCapacity.builder().value(404).unit("MB").build())
|
||||
.utilization(100)
|
||||
.build();
|
||||
assertEquals(detail,expected);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.ComputePoolMemoryUsageDetailSummaryEntry;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.memory.MemoryUsageDetails;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolMemoryUsage
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolMemoryUsageJAXBParsingTest")
|
||||
public class ComputePoolMemoryUsageJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
private SimpleDateFormatDateService dateService;
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
dateService = new SimpleDateFormatDateService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolMemoryUsage", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolMemoryUsage> parser = (Function<HttpResponse, ComputePoolMemoryUsage>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolMemoryUsage.xml");
|
||||
ComputePoolMemoryUsage memoryUsage = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(memoryUsage.getLinks());
|
||||
assertEquals(memoryUsage.getStartTime(), dateService.iso8601DateParse("2011-12-05T15:55:00.0Z"));
|
||||
assertEquals(memoryUsage.getEndTime(), dateService.iso8601DateParse("2011-12-06T15:55:00.0Z"));
|
||||
assertDetails(memoryUsage.getDetails());
|
||||
|
||||
Set<ComputePoolMemoryUsageDetailSummaryEntry> entries = memoryUsage.getDetails().getEntries();
|
||||
ComputePoolMemoryUsageDetailSummaryEntry first = Iterables.getFirst(entries, null);
|
||||
assertEquals(memoryUsage.getStartTime(),first.getTime());
|
||||
|
||||
ComputePoolMemoryUsageDetailSummaryEntry last = Iterables.getLast(entries, null);
|
||||
assertEquals(memoryUsage.getEndTime(),last.getTime());
|
||||
}
|
||||
|
||||
private void assertLinks(Set<Link> links) {
|
||||
assertEquals(links.size(),2);
|
||||
Link link = Iterables.get(links, 0);
|
||||
assertEquals(link.getName(),"Default Compute Pool");
|
||||
assertEquals(link.getRelationship(), Link.Relationship.UP);
|
||||
|
||||
Link link2 = Iterables.get(links, 1);
|
||||
assertEquals(link2.getHref(), URI.create("/cloudapi/ecloud/computepools/89/usage/memory/details?time=2011-12-05t15%3a55%3a00z"));
|
||||
assertEquals(link2.getType(), "application/vnd.tmrk.cloud.computePoolMemoryUsageDetail");
|
||||
assertEquals(link2.getRelationship(), Link.Relationship.DOWN);
|
||||
}
|
||||
|
||||
private void assertDetails(MemoryUsageDetails details) {
|
||||
assertEquals(details.getEntries().size(), 289);
|
||||
for(ComputePoolMemoryUsageDetailSummaryEntry entry: details.getEntries()) {
|
||||
assertDetail(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertDetail(ComputePoolMemoryUsageDetailSummaryEntry entry) {
|
||||
assertNotNull(entry.getTime());
|
||||
assertNotNull(entry.getValue());
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ import org.jclouds.rest.RestContextSpec;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.CpuComputeResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
@ -90,7 +91,7 @@ public class ComputePoolResourceSummaryJAXBParsingTest extends BaseRestClientTes
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testParseLocationWithJAXB() throws Exception {
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getResourceSummary",URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method, new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolResourceSummaryList
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolResourceSummaryListJAXBParsingTest")
|
||||
public class ComputePoolResourceSummaryListJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
private SimpleDateFormatDateService dateService;
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
dateService = new SimpleDateFormatDateService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getResourceSummaries", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolResourceSummaryList> parser = (Function<HttpResponse, ComputePoolResourceSummaryList>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolResourceSummaryList.xml");
|
||||
ComputePoolResourceSummaryList list = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(list.getLinks());
|
||||
// ComputePoolResourceSummary details are tested separately.
|
||||
assertEquals(list.getComputePoolResourceSummaries().size(),1);
|
||||
}
|
||||
|
||||
private void assertLinks(Set<Link> links) {
|
||||
assertEquals(links.size(),1);
|
||||
Link link = Iterables.getOnlyElement(links);
|
||||
assertEquals(link.getName(),"Beta Environment 01");
|
||||
assertEquals(link.getRelationship(), Link.Relationship.UP);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,28 @@
|
|||
<ComputePoolCpuUsageDetail
|
||||
href="/cloudapi/ecloud/computepools/89/usage/cpu/details?time=2011-12-05t10%3a10%3a00z"
|
||||
type="application/vnd.tmrk.cloud.computePoolCpuUsageDetail"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/computepools/89/usage/cpu"
|
||||
type="application/vnd.tmrk.cloud.computePoolCpuUsage" rel="up"/>
|
||||
</Links>
|
||||
<Time>2011-12-05T10:10:00Z</Time>
|
||||
<Value>
|
||||
<Unit>MHz</Unit>
|
||||
<Value>43</Value>
|
||||
</Value>
|
||||
<VirtualMachines>
|
||||
<VirtualMachine href="/cloudapi/ecloud/virtualmachines/5504"
|
||||
name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine">
|
||||
<Usage>
|
||||
<Unit>MHz</Unit>
|
||||
<Value>43</Value>
|
||||
</Usage>
|
||||
<Utilization>2</Utilization>
|
||||
</VirtualMachine>
|
||||
</VirtualMachines>
|
||||
</ComputePoolCpuUsageDetail>
|
|
@ -0,0 +1,17 @@
|
|||
<ComputePoolCpuUsageDetail
|
||||
href="/cloudapi/ecloud/computepools/89/usage/cpu/details?time=1974-12-05t10%3a10%3a00z"
|
||||
type="application/vnd.tmrk.cloud.computePoolCpuUsageDetail"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/computepools/89/usage/cpu"
|
||||
type="application/vnd.tmrk.cloud.computePoolCpuUsage" rel="up"/>
|
||||
</Links>
|
||||
<Time>1974-12-05T10:10:00Z</Time>
|
||||
<Value>
|
||||
<Unit>MHz</Unit>
|
||||
<Value>0</Value>
|
||||
</Value>
|
||||
</ComputePoolCpuUsageDetail>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
|||
<ComputePoolMemoryUsageDetail
|
||||
href="/cloudapi/ecloud/computepools/89/usage/memory/details?time=2011-12-05t15%3a55%3a00z"
|
||||
type="application/vnd.tmrk.cloud.computePoolMemoryUsageDetail"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/computepools/89/usage/memory"
|
||||
type="application/vnd.tmrk.cloud.computePoolMemoryUsage"
|
||||
rel="up"/>
|
||||
</Links>
|
||||
<Time>2011-12-05T15:55:00Z</Time>
|
||||
<Value>
|
||||
<Unit>MB</Unit>
|
||||
<Value>404</Value>
|
||||
</Value>
|
||||
<VirtualMachines>
|
||||
<VirtualMachine href="/cloudapi/ecloud/virtualmachines/5504"
|
||||
name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine">
|
||||
<Usage>
|
||||
<Unit>MB</Unit>
|
||||
<Value>404</Value>
|
||||
</Usage>
|
||||
<Utilization>100</Utilization>
|
||||
</VirtualMachine>
|
||||
</VirtualMachines>
|
||||
</ComputePoolMemoryUsageDetail>
|
|
@ -0,0 +1,18 @@
|
|||
<ComputePoolMemoryUsageDetail
|
||||
href="/cloudapi/ecloud/computepools/89/usage/memory/details?time=1974-12-05t15%3a55%3a00z"
|
||||
type="application/vnd.tmrk.cloud.computePoolMemoryUsageDetail"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/computepools/89/usage/memory"
|
||||
type="application/vnd.tmrk.cloud.computePoolMemoryUsage"
|
||||
rel="up"/>
|
||||
</Links>
|
||||
<Time>1974-12-05T15:55:00Z</Time>
|
||||
<Value>
|
||||
<Unit>MB</Unit>
|
||||
<Value>0</Value>
|
||||
</Value>
|
||||
</ComputePoolMemoryUsageDetail>
|
Loading…
Reference in New Issue