diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/BillingItemVirtualGuest.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/BillingItemVirtualGuest.java new file mode 100644 index 0000000000..1351be3f3b --- /dev/null +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/BillingItemVirtualGuest.java @@ -0,0 +1,101 @@ +/** + * 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.softlayer.domain; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Strings.emptyToNull; + +/** + * + * @author Jason King + * @see + */ +public class BillingItemVirtualGuest implements Comparable { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private long id = -1; + + public Builder id(long id) { + this.id = id; + return this; + } + + public static Builder fromBillingItemVirtualGuest(BillingItemVirtualGuest in) { + return BillingItemVirtualGuest.builder().id(in.getId()); + } + } + + private long id = -1; + + // for deserializer + BillingItemVirtualGuest() { + + } + + public BillingItemVirtualGuest(long id) { + this.id = id; + } + + @Override + public int compareTo(BillingItemVirtualGuest arg0) { + return new Long(id).compareTo(arg0.getId()); + } + + /** + * @return The unique identifier for this billing item. + */ + public long getId() { + return id; + } + + public Builder toBuilder() { + return Builder.fromBillingItemVirtualGuest(this); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BillingItemVirtualGuest other = (BillingItemVirtualGuest) obj; + if (id != other.id) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + "]"; + } +} diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java index 7823d95f0a..ffcf4f0292 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java @@ -86,6 +86,8 @@ public class VirtualGuest implements Comparable { private String primaryBackendIpAddress; private String primaryIpAddress; + private BillingItemVirtualGuest billingItem; + // for deserializer VirtualGuest() { @@ -95,7 +97,7 @@ public class VirtualGuest implements Comparable { String fullyQualifiedDomainName, String hostname, long id, Date lastVerifiedDate, int maxCpu, String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes, boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress, - String primaryIpAddress) { + String primaryIpAddress,BillingItemVirtualGuest billingItem) { this.accountId = accountId; this.createDate = createDate; this.dedicatedAccountHostOnly = dedicatedAccountHostOnly; @@ -116,6 +118,7 @@ public class VirtualGuest implements Comparable { this.uuid = uuid; this.primaryBackendIpAddress = primaryBackendIpAddress; this.primaryIpAddress = primaryIpAddress; + this.billingItem = billingItem; } @Override @@ -266,6 +269,13 @@ public class VirtualGuest implements Comparable { return primaryIpAddress; } + /** + * @return The billing item for a CloudLayer Compute Instance. + */ + public BillingItemVirtualGuest getBillingItem() { + return billingItem; + } + @Override public int hashCode() { final int prime = 31; @@ -290,6 +300,7 @@ public class VirtualGuest implements Comparable { result = prime * result + startCpus; result = prime * result + statusId; result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); + result = prime * result + billingItem.hashCode(); return result; } @@ -378,6 +389,8 @@ public class VirtualGuest implements Comparable { return false; } else if (!uuid.equals(other.uuid)) return false; + if (!billingItem.equals(other.billingItem)) + return false; return true; } diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java index 78f327b97b..83ce200813 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java @@ -48,7 +48,7 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(BasicAuthentication.class) @Path("/v{jclouds.api-version}") public interface VirtualGuestAsyncClient { - public static String GUEST_MASK = "powerState;networkVlans;operatingSystem.passwords;datacenter"; + public static String GUEST_MASK = "powerState;networkVlans;operatingSystem.passwords;datacenter;virtualGuests.billingItem"; /** * @see VirtualGuestClient#listVirtualGuests diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java index 26c271cef9..45c5e33901 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java @@ -47,7 +47,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest 0 : billingItem; } }