As in JCLOUDS-991 it appears size is missing as a UsageResponse parameter, 
particularily for Volume usages.  This commit adds it into the UsageRecord 
class.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/c73b82b5
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/c73b82b5
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/c73b82b5

Branch: refs/heads/master
Commit: c73b82b58b6ad0270bc24402ee44ceeb83fad978
Parents: cf0e659
Author: John McDonnell <[email protected]>
Authored: Mon Aug 17 21:29:40 2015 +0100
Committer: Ignasi Barrera <[email protected]>
Committed: Wed Oct 7 20:42:47 2015 +0200

----------------------------------------------------------------------
 .../jclouds/cloudstack/domain/UsageRecord.java  | 28 ++++++++++++++++----
 .../parse/ListUsageRecordsResponseTest.java     |  3 ++-
 2 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/c73b82b5/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java
----------------------------------------------------------------------
diff --git 
a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java 
b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java
index fe54b70..164c9ae 100644
--- 
a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java
+++ 
b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java
@@ -111,6 +111,7 @@ public class UsageRecord {
       protected boolean isSourceNAT;
       protected double rawUsageHours;
       protected String usage;
+      protected Long size;
       protected String type;
       protected UsageType usageType;
 
@@ -257,6 +258,14 @@ public class UsageRecord {
          this.usage = usage;
          return self();
       }
+      
+      /**
+       * @see UsageRecord#getSize()
+       */
+      public T size(Long size) {
+         this.size = size;
+         return self();
+      }
 
       /**
        * @see UsageRecord#getType()
@@ -277,7 +286,7 @@ public class UsageRecord {
       public UsageRecord build() {
          return new UsageRecord(id, description, accountId, accountName, 
domainId, startDate, endDate, assignDate, releaseDate,
                zoneId, virtualMachineId, virtualMachineName, 
serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
-               usage, type, usageType);
+               usage, size, type, usageType);
       }
 
       public T fromUsageRecord(UsageRecord in) {
@@ -300,6 +309,7 @@ public class UsageRecord {
                .isSourceNAT(in.isSourceNAT())
                .rawUsageHours(in.getRawUsageHours())
                .usage(in.getUsage())
+               .size(in.getSize())
                .type(in.getType())
                .usageType(in.getUsageType());
       }
@@ -330,19 +340,21 @@ public class UsageRecord {
    private final boolean isSourceNAT;
    private final double rawUsageHours;
    private final String usage;
+   private final Long size;
    private final String type;
    private final UsageType usageType;
 
    @ConstructorProperties({
          "usageid", "description", "accountid", "account", "domainid", 
"startdate", "enddate", "assigndate", "releasedate",
          "zoneid", "virtualmachineid", "name", "offeringid", "templateid", 
"ipaddress", "issourcenat", "rawusage", "usage",
-         "type", "usagetype"
+         "size", "type", "usagetype"
    })
    protected UsageRecord(String id, @Nullable String description, @Nullable 
String accountId, @Nullable String accountName,
                          @Nullable String domainId, @Nullable Date startDate, 
@Nullable Date endDate, @Nullable Date assignDate,
                          @Nullable String releaseDate, @Nullable String 
zoneId, @Nullable String virtualMachineId, @Nullable String virtualMachineName,
                          @Nullable String serviceOfferingId, @Nullable String 
templateId, @Nullable String ipAddress,
-                         boolean isSourceNAT, double rawUsageHours, @Nullable 
String usage, @Nullable String type, @Nullable UsageType usageType) {
+                         boolean isSourceNAT, double rawUsageHours, @Nullable 
String usage, @Nullable Long size,
+                         @Nullable String type, @Nullable UsageType usageType) 
{
       this.id = id;
       this.description = description;
       this.accountId = accountId;
@@ -361,6 +373,7 @@ public class UsageRecord {
       this.isSourceNAT = isSourceNAT;
       this.rawUsageHours = rawUsageHours;
       this.usage = usage;
+      this.size = size;
       this.type = type;
       this.usageType = usageType;
    }
@@ -451,6 +464,10 @@ public class UsageRecord {
    public String getUsage() {
       return this.usage;
    }
+   
+   public Long getSize() {
+      return this.size;
+   }
 
    @Nullable
    public String getType() {
@@ -466,7 +483,7 @@ public class UsageRecord {
    public int hashCode() {
       return Objects.hashCode(id, description, accountId, accountName, 
domainId, startDate, endDate, assignDate, releaseDate,
             zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, 
templateId, ipAddress, isSourceNAT, rawUsageHours,
-            usage, type, usageType);
+            size, usage, type, usageType);
    }
 
    @Override
@@ -492,6 +509,7 @@ public class UsageRecord {
             && Objects.equal(this.isSourceNAT, that.isSourceNAT)
             && Objects.equal(this.rawUsageHours, that.rawUsageHours)
             && Objects.equal(this.usage, that.usage)
+            && Objects.equal(this.size, that.size)
             && Objects.equal(this.type, that.type)
             && Objects.equal(this.usageType, that.usageType);
    }
@@ -503,7 +521,7 @@ public class UsageRecord {
             .add("releaseDate", releaseDate).add("zoneId", 
zoneId).add("virtualMachineId", virtualMachineId)
             .add("virtualMachineName", 
virtualMachineName).add("serviceOfferingId", 
serviceOfferingId).add("templateId", templateId)
             .add("ipAddress", ipAddress).add("isSourceNAT", 
isSourceNAT).add("rawUsageHours", rawUsageHours).add("usage", usage)
-            .add("type", type).add("usageType", usageType);
+            .add("size", size).add("type", type).add("usageType", usageType);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/jclouds/blob/c73b82b5/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListUsageRecordsResponseTest.java
----------------------------------------------------------------------
diff --git 
a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListUsageRecordsResponseTest.java
 
b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListUsageRecordsResponseTest.java
index 9ecd895..8a4fd25 100644
--- 
a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListUsageRecordsResponseTest.java
+++ 
b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListUsageRecordsResponseTest.java
@@ -60,7 +60,8 @@ public class ListUsageRecordsResponseTest extends 
BaseSetParserTest<UsageRecord>
                .accountName("admin").accountId("2").domainId("1").zoneId("1")
                .description("Template Id:203 Size:3117171712")
                .usage("24 
Hrs").usageType(UsageRecord.UsageType.TEMPLATE).rawUsageHours(24)
-            .templateId("0").id("203").startDate(start).endDate(end).build());
+               .size(3117171712l).templateId("0").id("203")
+               .startDate(start).endDate(end).build());
 
    }
    

Reply via email to