You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/12 23:29:38 UTC

git commit: JCLOUDS-241. Added type, page, and pagesize to ListUsageRecordsOptions and corresponding test cases. These are optional parameters for listUsageRecords http://cloudstack.apache.org/docs/api/apidocs-4.1/root_admin/listUsageRecords.html

Updated Branches:
  refs/heads/master e0ea017a5 -> 97c3a203f


JCLOUDS-241. Added type, page, and pagesize to ListUsageRecordsOptions
and corresponding test cases. These are optional parameters for
listUsageRecords
http://cloudstack.apache.org/docs/api/apidocs-4.1/root_admin/listUsageRecords.html

Removed null check on usage id because this can be null.


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

Branch: refs/heads/master
Commit: 97c3a203f4538eb760886c2456248ae7a1b9aed1
Parents: e0ea017
Author: einsdo <ed...@ssglimited.com>
Authored: Thu Aug 8 19:14:42 2013 -0500
Committer: Andrew Bayer <an...@gmail.com>
Committed: Mon Aug 12 14:28:49 2013 -0700

----------------------------------------------------------------------
 .../jclouds/cloudstack/domain/UsageRecord.java  |  2 +-
 .../options/ListUsageRecordsOptions.java        | 32 ++++++++++++++++++++
 .../options/ListUsageRecordsOptionsTest.java    | 19 ++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/97c3a203/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 4f3489c..d6afa22 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
@@ -345,7 +345,7 @@ public class UsageRecord {
                          @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) {
-      this.id = checkNotNull(id, "id");
+      this.id = id;
       this.description = description;
       this.accountId = accountId;
       this.accountName = accountName;

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/97c3a203/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListUsageRecordsOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListUsageRecordsOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListUsageRecordsOptions.java
index 324e2fc..c8d732b 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListUsageRecordsOptions.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListUsageRecordsOptions.java
@@ -52,6 +52,22 @@ public class ListUsageRecordsOptions extends AccountInDomainOptions {
          ListUsageRecordsOptions options = new ListUsageRecordsOptions();
          return options.keyword(keyword);
       }
+	  
+      public static ListUsageRecordsOptions type(String type) {
+         ListUsageRecordsOptions options = new ListUsageRecordsOptions();
+         return options.type(type);
+      }
+      
+      public static ListUsageRecordsOptions page(String page) {
+         ListUsageRecordsOptions options = new ListUsageRecordsOptions();
+         return options.page(page);
+      }
+      
+      public static ListUsageRecordsOptions pageSize(String pageSize) {
+         ListUsageRecordsOptions options = new ListUsageRecordsOptions();
+         return options.pageSize(pageSize);
+      }
+
    }
 
    @Override
@@ -78,4 +94,20 @@ public class ListUsageRecordsOptions extends AccountInDomainOptions {
       this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword));
       return this;
    }
+   
+   public ListUsageRecordsOptions type(String type) {
+      this.queryParameters.replaceValues("type", ImmutableSet.of(type));
+      return this;
+   }
+   
+   public ListUsageRecordsOptions page(String page) {
+      this.queryParameters.replaceValues("page", ImmutableSet.of(page));
+      return this;
+   }
+   
+   public ListUsageRecordsOptions pageSize(String pageSize) {
+      this.queryParameters.replaceValues("pagesize", ImmutableSet.of(pageSize));
+      return this;
+   }
+	
 }

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/97c3a203/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListUsageRecordsOptionsTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListUsageRecordsOptionsTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListUsageRecordsOptionsTest.java
index c3c127c..34c8ec2 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListUsageRecordsOptionsTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListUsageRecordsOptionsTest.java
@@ -20,6 +20,9 @@ import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.acc
 import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.accountInDomain;
 import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.domainId;
 import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.keyword;
+import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.page;
+import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.pageSize;
+import static org.jclouds.cloudstack.options.ListUsageRecordsOptions.Builder.type;
 import static org.testng.Assert.assertEquals;
 
 import org.testng.annotations.Test;
@@ -75,4 +78,20 @@ public class ListUsageRecordsOptionsTest {
       ListUsageRecordsOptions options = keyword("bob");
       assertEquals(ImmutableSet.of("bob"), options.buildQueryParameters().get("keyword"));
    }
+   
+       public void testTypeStatic() {
+        ListUsageRecordsOptions options = type("3");
+        assertEquals(ImmutableSet.of("3"), options.buildQueryParameters().get("type"));
+    }
+
+    public void testPageStatic() {
+        ListUsageRecordsOptions options = page("1");
+        assertEquals(ImmutableSet.of("1"), options.buildQueryParameters().get("page"));
+    }
+
+    public void testPageSizeStatic() {
+        ListUsageRecordsOptions options = pageSize("500");
+        assertEquals(ImmutableSet.of("500"), options.buildQueryParameters().get("pagesize"));
+    }
+	
 }