Repository: jclouds
Updated Branches:
  refs/heads/1.9.x 29b503afd -> 9f85213b4


AS per JCLOUDS-1012 project and projectId parameters are not supported.  This 
commits adds the 2 parameters to the usage response.


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

Branch: refs/heads/1.9.x
Commit: 9f85213b4fc0960d0c081268208acf638c261b76
Parents: 29b503a
Author: John McDonnell <[email protected]>
Authored: Sat Oct 10 12:14:23 2015 +0100
Committer: Ignasi Barrera <[email protected]>
Committed: Tue Oct 13 11:02:38 2015 +0200

----------------------------------------------------------------------
 .../jclouds/cloudstack/domain/UsageRecord.java  | 49 +++++++++++++++++---
 .../parse/ListUsageRecordsResponseTest.java     |  2 +-
 .../resources/listusagerecordsresponse.json     |  2 +-
 3 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/9f85213b/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 164c9ae..fb0dda6 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
@@ -114,6 +114,8 @@ public class UsageRecord {
       protected Long size;
       protected String type;
       protected UsageType usageType;
+      protected String project;
+      protected String projectId;
 
       /**
        * @see UsageRecord#getId()
@@ -283,10 +285,25 @@ public class UsageRecord {
          return self();
       }
 
+      /**
+       * @see UsageRecord#getProject()
+       */
+      public T project(String project) {
+         this.project = project;
+         return self();
+      }
+      
+      /**
+       * @see UsageRecord#getProjectId()
+       */
+      public T projectId(String projectId) {
+         this.projectId = projectId;
+         return self();
+      }
       public UsageRecord build() {
          return new UsageRecord(id, description, accountId, accountName, 
domainId, startDate, endDate, assignDate, releaseDate,
                zoneId, virtualMachineId, virtualMachineName, 
serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
-               usage, size, type, usageType);
+               usage, size, type, usageType, project, projectId);
       }
 
       public T fromUsageRecord(UsageRecord in) {
@@ -311,7 +328,9 @@ public class UsageRecord {
                .usage(in.getUsage())
                .size(in.getSize())
                .type(in.getType())
-               .usageType(in.getUsageType());
+               .usageType(in.getUsageType())
+               .project(in.getProject())
+               .projectId(in.getProjectId());
       }
    }
 
@@ -343,18 +362,20 @@ public class UsageRecord {
    private final Long size;
    private final String type;
    private final UsageType usageType;
+   private final String project;
+   private final String projectId;
 
    @ConstructorProperties({
          "usageid", "description", "accountid", "account", "domainid", 
"startdate", "enddate", "assigndate", "releasedate",
          "zoneid", "virtualmachineid", "name", "offeringid", "templateid", 
"ipaddress", "issourcenat", "rawusage", "usage",
-         "size", "type", "usagetype"
+         "size", "type", "usagetype", "project", "projectId"
    })
    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 Long size,
-                         @Nullable String type, @Nullable UsageType usageType) 
{
+                         @Nullable String type, @Nullable UsageType usageType, 
@Nullable String project, @Nullable String projectId) {
       this.id = id;
       this.description = description;
       this.accountId = accountId;
@@ -376,6 +397,8 @@ public class UsageRecord {
       this.size = size;
       this.type = type;
       this.usageType = usageType;
+      this.project = project;
+      this.projectId = projectId;
    }
 
    public String getId() {
@@ -478,12 +501,22 @@ public class UsageRecord {
    public UsageType getUsageType() {
       return this.usageType;
    }
+   
+   @Nullable
+   public String getProject() {
+      return this.project;
+   }
+   
+   @Nullable
+   public String getProjectId() {
+      return this.projectId;
+   }
 
    @Override
    public int hashCode() {
       return Objects.hashCode(id, description, accountId, accountName, 
domainId, startDate, endDate, assignDate, releaseDate,
             zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, 
templateId, ipAddress, isSourceNAT, rawUsageHours,
-            size, usage, type, usageType);
+            size, usage, type, usageType, project, projectId);
    }
 
    @Override
@@ -511,7 +544,9 @@ public class UsageRecord {
             && Objects.equal(this.usage, that.usage)
             && Objects.equal(this.size, that.size)
             && Objects.equal(this.type, that.type)
-            && Objects.equal(this.usageType, that.usageType);
+            && Objects.equal(this.usageType, that.usageType)
+            && Objects.equal(this.project, that.project)
+            && Objects.equal(this.projectId, that.projectId);
    }
 
    protected ToStringHelper string() {
@@ -521,7 +556,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("size", size).add("type", type).add("usageType", usageType);
+            .add("size", size).add("type", type).add("usageType", 
usageType).add("project", project).add("projectId", projectId);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/jclouds/blob/9f85213b/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 8a4fd25..a55bf7e 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,7 @@ 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)
-               .size(3117171712l).templateId("0").id("203")
+               
.size(3117171712l).templateId("0").id("203").project("project1").projectId("1")
                .startDate(start).endDate(end).build());
 
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/9f85213b/apis/cloudstack/src/test/resources/listusagerecordsresponse.json
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/resources/listusagerecordsresponse.json 
b/apis/cloudstack/src/test/resources/listusagerecordsresponse.json
index 5175f70..73823b4 100644
--- a/apis/cloudstack/src/test/resources/listusagerecordsresponse.json
+++ b/apis/cloudstack/src/test/resources/listusagerecordsresponse.json
@@ -1 +1 @@
-{ "listusagerecordsresponse" : { "count":1 ,"usagerecord" : [  
{"account":"admin","accountid":2,"domainid":1,"zoneid":1,"description":"Template
 Id:203 Size:3117171712","usage":"24 
Hrs","usagetype":7,"rawusage":"24","templateid":0,"usageid":203,"size":3117171712,"startdate":"2011-12-15'T'00:00:00+00:00","enddate":"2011-12-15'T'23:59:59+00:00"}
 ] } }
\ No newline at end of file
+{ "listusagerecordsresponse" : { "count":1 ,"usagerecord" : [  
{"account":"admin","accountid":2,"domainid":1,"zoneid":1,"description":"Template
 Id:203 Size:3117171712","usage":"24 
Hrs","usagetype":7,"rawusage":"24","templateid":0,"usageid":203,"size":3117171712,"project":"project1","projectId":1,"startdate":"2011-12-15'T'00:00:00+00:00","enddate":"2011-12-15'T'23:59:59+00:00"}
 ] } }
\ No newline at end of file

Reply via email to