You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2014/01/17 21:08:59 UTC
[1/3] Renames multiple domain classes for consistency
Updated Branches:
refs/heads/1.7.x 24a37bde7 -> 0a8010bef
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java
index cd1c664..a99f32d 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiLiveTest.java
@@ -31,11 +31,11 @@ import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration.LaunchConfigurationType;
import org.jclouds.rackspace.autoscale.v1.domain.LoadBalancer;
import org.jclouds.rackspace.autoscale.v1.domain.Personality;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyScheduleType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyScheduleType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -89,9 +89,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.contents("VGhpcyBpcyBhIHRlc3QgZmlsZS4=").build()))
.type(LaunchConfigurationType.LAUNCH_SERVER).build();
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder().cooldown(3).type(ScalingPolicyType.WEBHOOK)
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder().cooldown(3).type(ScalingPolicyType.WEBHOOK)
.name("scale up by 1").targetType(ScalingPolicyTargetType.INCREMENTAL).target("1").build();
scalingPolicies.add(scalingPolicy);
@@ -152,9 +152,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by one server")
@@ -163,7 +163,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
assertNotNull(scalingPolicyResponse.iterator().next().getId());
assertEquals(scalingPolicyResponse.iterator().next().getCooldown(), 3);
assertEquals(scalingPolicyResponse.iterator().next().getTarget(), "1");
@@ -176,9 +176,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.SCHEDULE)
.name("scale up by one server")
@@ -188,7 +188,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
assertNotNull(scalingPolicyResponse.iterator().next().getId());
assertEquals(scalingPolicyResponse.iterator().next().getCooldown(), 3);
assertEquals(scalingPolicyResponse.iterator().next().getTarget(), "1");
@@ -203,9 +203,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.SCHEDULE)
.name("scale up by one server")
@@ -215,7 +215,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
assertNotNull(scalingPolicyResponse.iterator().next().getId());
assertEquals(scalingPolicyResponse.iterator().next().getCooldown(), 3);
assertEquals(scalingPolicyResponse.iterator().next().getTarget(), "1");
@@ -230,7 +230,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.list();
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.list();
assertNotNull(scalingPolicyResponse.iterator().next().getId());
}
}
@@ -242,8 +242,8 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
assertNotNull(policyApi);
- ScalingPolicyResponse listResponse = policyApi.list().iterator().next();
- ScalingPolicyResponse getResponse = policyApi.get(listResponse.getId());
+ ScalingPolicy listResponse = policyApi.list().iterator().next();
+ ScalingPolicy getResponse = policyApi.get(listResponse.getId());
assertEquals(listResponse.getId(), getResponse.getId());
assertEquals(listResponse.getName(), getResponse.getName());
assertEquals(listResponse.getCooldown(), getResponse.getCooldown());
@@ -260,9 +260,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by one server")
@@ -271,7 +271,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- ScalingPolicy updated = ScalingPolicy.builder()
+ CreateScalingPolicy updated = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by 2 PERCENT server")
@@ -280,14 +280,14 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
String policyId = scalingPolicyResponse.iterator().next().getId();
assertNotNull(policyId);
boolean result = policyApi.update(policyId, updated);
assertTrue(result);
- ScalingPolicyResponse updatedResponse = policyApi.get(policyId);
+ ScalingPolicy updatedResponse = policyApi.get(policyId);
assertNotNull(updatedResponse.getId());
assertEquals(updatedResponse.getCooldown(), 3);
@@ -304,9 +304,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by one server")
@@ -315,7 +315,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
String policyId = scalingPolicyResponse.iterator().next().getId();
assertNotNull(policyId);
@@ -330,9 +330,9 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, created.get(zone).get(0).getId());
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by 0 server")
@@ -341,7 +341,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
String policyId = scalingPolicyResponse.iterator().next().getId();
assertNotNull(policyId);
@@ -358,15 +358,15 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
for (Group group : created.get(zone)) {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, group.getId());
if(policyApi == null)continue;
- for(ScalingPolicyResponse sgr : policyApi.list()) {
+ for(ScalingPolicy sgr : policyApi.list()) {
if(!policyApi.delete(sgr.getId())) {
System.out.println("Could not delete an autoscale policy after tests!");
}
}
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(3)
.type(ScalingPolicyType.WEBHOOK)
.name("0 machines")
@@ -375,7 +375,7 @@ public class ScalingPolicyApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
String policyId = scalingPolicyResponse.first().get().getId();
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiMockTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiMockTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiMockTest.java
index 0a324cc..f62f287 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiMockTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/ScalingPolicyApiMockTest.java
@@ -26,11 +26,11 @@ import java.io.IOException;
import java.util.List;
import org.jclouds.rackspace.autoscale.v1.AutoscaleApi;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyScheduleType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyScheduleType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiMockTest;
import org.testng.annotations.Test;
@@ -56,9 +56,9 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(1800)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by one server")
@@ -67,7 +67,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.create(scalingPolicies);
/*
* Check request
@@ -99,9 +99,9 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(1800)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by one server")
@@ -110,7 +110,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.create(scalingPolicies);
/*
* Check request
@@ -136,9 +136,9 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(2)
.type(ScalingPolicyType.SCHEDULE)
.name("scale down by 5.5 percent at 11pm")
@@ -148,7 +148,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.create(scalingPolicies);
/*
* Check request
@@ -183,9 +183,9 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(2)
.type(ScalingPolicyType.SCHEDULE)
.name("scale down by 5.5 percent on the 5th")
@@ -195,7 +195,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.create(scalingPolicies);
/*
* Check request
@@ -230,7 +230,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.list();
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.list();
/*
* Check request
@@ -262,7 +262,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = api.list();
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = api.list();
/*
* Check request
@@ -288,7 +288,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- ScalingPolicyResponse scalingPolicyResponse = api.get("policyId");
+ ScalingPolicy scalingPolicyResponse = api.get("policyId");
/*
* Check request
@@ -319,7 +319,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- ScalingPolicyResponse scalingPolicyResponse = api.get("policyId");
+ ScalingPolicy scalingPolicyResponse = api.get("policyId");
/*
* Check request
@@ -345,7 +345,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(6)
.type(ScalingPolicyType.WEBHOOK)
.name("scale down by 5 percent")
@@ -379,7 +379,7 @@ public class ScalingPolicyApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
PolicyApi api = autoscaleApi.getPolicyApiForZoneAndGroup("DFW", "groupId1");
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(6)
.type(ScalingPolicyType.WEBHOOK)
.name("scale down by 5 percent")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java
index 58adad6..2e84fd9 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiLiveTest.java
@@ -36,12 +36,12 @@ import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration.LaunchConfigurationType;
import org.jclouds.rackspace.autoscale.v1.domain.LoadBalancer;
import org.jclouds.rackspace.autoscale.v1.domain.Personality;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateWebhook;
import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
-import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiLiveTest;
import org.jclouds.rackspace.autoscale.v1.utils.AutoscaleUtils;
import org.testng.annotations.AfterClass;
@@ -96,9 +96,9 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
.contents("VGhpcyBpcyBhIHRlc3QgZmlsZS4=").build()))
.type(LaunchConfigurationType.LAUNCH_SERVER).build();
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder().cooldown(3).type(ScalingPolicyType.WEBHOOK)
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder().cooldown(3).type(ScalingPolicyType.WEBHOOK)
.name("scale up by 1").targetType(ScalingPolicyTargetType.INCREMENTAL).target("1").build();
scalingPolicies.add(scalingPolicy);
@@ -161,7 +161,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (String zone : api.getConfiguredZones()) {
Group g = created.get(zone).get(0);
WebhookApi webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), g.getScalingPolicies().iterator().next().getId());
- WebhookResponse webhook = webhookApi.create("test1", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
+ Webhook webhook = webhookApi.create("test1", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
assertEquals(webhook.getName(), "test1");
assertEquals(webhook.getMetadata().get("notes"), "test metadata");
@@ -173,10 +173,10 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (String zone : api.getConfiguredZones()) {
Group g = created.get(zone).get(0);
WebhookApi webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), g.getScalingPolicies().iterator().next().getId());
- FluentIterable<WebhookResponse> webhookResponse = webhookApi.create(
+ FluentIterable<Webhook> webhookResponse = webhookApi.create(
ImmutableList.of(
- Webhook.builder().name("test5").metadata(null).build(),
- Webhook.builder().name("test6").metadata(ImmutableMap.<String, Object>of("notes2", "different test")).build()
+ CreateWebhook.builder().name("test5").metadata(null).build(),
+ CreateWebhook.builder().name("test6").metadata(ImmutableMap.<String, Object>of("notes2", "different test")).build()
));
assertEquals(webhookResponse.get(0).getName(), "test5");
@@ -194,7 +194,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
String webhookId = webhookApi.list().first().get().getId();
assertTrue( webhookApi.update(webhookId, "updated_name", ImmutableMap.<String, Object>of()) );
- WebhookResponse webhook= webhookApi.get(webhookId);
+ Webhook webhook= webhookApi.get(webhookId);
assertEquals(webhook.getName(), "updated_name");
assertTrue( webhook.getMetadata().isEmpty() );
}
@@ -206,11 +206,11 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
Group g = created.get(zone).get(0);
WebhookApi webhookApi;
boolean foundWebhook = false;
- for (ScalingPolicyResponse sp : g.getScalingPolicies()) {
+ for (ScalingPolicy sp : g.getScalingPolicies()) {
webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), sp.getId());
- WebhookResponse webhookResponse = webhookApi.list().first().get();
+ Webhook webhookResponse = webhookApi.list().first().get();
if (webhookResponse != null) {
- WebhookResponse webhookGet = webhookApi.get(webhookResponse.getId());
+ Webhook webhookGet = webhookApi.get(webhookResponse.getId());
assertEquals(webhookResponse, webhookGet);
foundWebhook = true;
}
@@ -233,7 +233,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (String zone : api.getConfiguredZones()) {
Group g = created.get(zone).get(0);
WebhookApi webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), g.getScalingPolicies().iterator().next().getId());
- WebhookResponse webhook = webhookApi.create("test1", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
+ Webhook webhook = webhookApi.create("test1", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
assertEquals(webhook.getName(), "test1");
assertEquals(webhook.getMetadata().get("notes"), "test metadata");
@@ -248,7 +248,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (String zone : api.getConfiguredZones()) {
Group g = created.get(zone).get(0);
WebhookApi webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), g.getScalingPolicies().iterator().next().getId());
- WebhookResponse webhook = webhookApi.create("test_execute", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
+ Webhook webhook = webhookApi.create("test_execute", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
assertTrue( AutoscaleUtils.execute(webhook.getAnonymousExecutionURI().get()) , " for " + webhook + " in " + zone);
}
@@ -259,7 +259,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (String zone : api.getConfiguredZones()) {
Group g = created.get(zone).get(0);
WebhookApi webhookApi = api.getWebhookApiForZoneAndGroupAndPolicy(zone, g.getId(), g.getScalingPolicies().iterator().next().getId());
- WebhookResponse webhook = webhookApi.create("test_execute_fail", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
+ Webhook webhook = webhookApi.create("test_execute_fail", ImmutableMap.<String, Object>of("notes", "test metadata")).first().get();
URI uri = new URI(webhook.getAnonymousExecutionURI().get().toString() + "123");
assertFalse( AutoscaleUtils.execute(uri) );
@@ -274,15 +274,15 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
for (Group group : created.get(zone)) {
PolicyApi policyApi = api.getPolicyApiForZoneAndGroup(zone, group.getId());
if(policyApi == null)continue;
- for(ScalingPolicyResponse sgr : policyApi.list()) {
+ for(ScalingPolicy sgr : policyApi.list()) {
if(!policyApi.delete(sgr.getId())) {
System.out.println("Could not delete an autoscale policy after tests!");
}
}
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(2)
.type(ScalingPolicyType.WEBHOOK)
.name("0 machines")
@@ -291,7 +291,7 @@ public class WebhookApiLiveTest extends BaseAutoscaleApiLiveTest {
.build();
scalingPolicies.add(scalingPolicy);
- FluentIterable<ScalingPolicyResponse> scalingPolicyResponse = policyApi.create(scalingPolicies);
+ FluentIterable<ScalingPolicy> scalingPolicyResponse = policyApi.create(scalingPolicies);
String policyId = scalingPolicyResponse.iterator().next().getId();
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiMockTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiMockTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiMockTest.java
index de3a3db..da39ec3 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiMockTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApiMockTest.java
@@ -24,8 +24,8 @@ import static org.testng.Assert.assertTrue;
import java.io.IOException;
import org.jclouds.rackspace.autoscale.v1.AutoscaleApi;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateWebhook;
import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
-import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiMockTest;
import org.testng.annotations.Test;
@@ -52,7 +52,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.create("PagerDuty", ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook"));
+ FluentIterable<Webhook> webhooks = api.create("PagerDuty", ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook"));
/*
* Check request
@@ -79,7 +79,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.create("PagerDuty", ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook"));
+ FluentIterable<Webhook> webhooks = api.create("PagerDuty", ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook"));
/*
* Check request
@@ -105,9 +105,9 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.create(ImmutableList.of(
- Webhook.builder().name("PagerDuty").metadata(ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook")).build(),
- Webhook.builder().name("Nagios").metadata(ImmutableMap.<String, Object>of()).build()
+ FluentIterable<Webhook> webhooks = api.create(ImmutableList.of(
+ CreateWebhook.builder().name("PagerDuty").metadata(ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook")).build(),
+ CreateWebhook.builder().name("Nagios").metadata(ImmutableMap.<String, Object>of()).build()
));
/*
@@ -136,9 +136,9 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.create(ImmutableList.of(
- Webhook.builder().name("PagerDuty").metadata(ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook")).build(),
- Webhook.builder().name("Nagios").metadata(ImmutableMap.<String, Object>of()).build()
+ FluentIterable<Webhook> webhooks = api.create(ImmutableList.of(
+ CreateWebhook.builder().name("PagerDuty").metadata(ImmutableMap.<String, Object>of("notes", "PagerDuty will fire this webhook")).build(),
+ CreateWebhook.builder().name("Nagios").metadata(ImmutableMap.<String, Object>of()).build()
));
/*
@@ -165,7 +165,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.list();
+ FluentIterable<Webhook> webhooks = api.list();
/*
* Check request
@@ -193,7 +193,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- FluentIterable<WebhookResponse> webhooks = api.list();
+ FluentIterable<Webhook> webhooks = api.list();
/*
* Check request
@@ -271,7 +271,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- WebhookResponse webhook = api.get("5555");
+ Webhook webhook = api.get("5555");
/*
* Check request
@@ -298,7 +298,7 @@ public class WebhookApiMockTest extends BaseAutoscaleApiMockTest {
AutoscaleApi autoscaleApi = api(server.getUrl("/").toString(), "rackspace-autoscale", overrides);
WebhookApi api = autoscaleApi.getWebhookApiForZoneAndGroupAndPolicy("DFW", "1234567890", "321456");
- WebhookResponse webhook = api.get("5555");
+ Webhook webhook = api.get("5555");
/*
* Check request
[3/3] git commit: JCLOUDS-299: Added copy method to Object API
Posted by za...@apache.org.
JCLOUDS-299: Added copy method to Object API
- Added copy method
- Added CopyObjectException file
- Added SwiftHeaders file
- Updated the Swift error handler
- Added CreateContainerOptions.NONE and updated refs
- Added Region specific configuration for live tests
- Added support for LocationConstants.REGION
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/commit/0a8010be
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/tree/0a8010be
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/diff/0a8010be
Branch: refs/heads/1.7.x
Commit: 0a8010bef6046798122aef3532ebd78aba8315ce
Parents: 4f2fddb
Author: Jeremy Daggett <je...@rackspace.com>
Authored: Tue Jan 7 12:52:04 2014 -0800
Committer: Zack Shoylev <za...@rackspace.com>
Committed: Fri Jan 17 14:05:11 2014 -0600
----------------------------------------------------------------------
.../openstack/swift/v1/CopyObjectException.java | 51 ++++
.../openstack/swift/v1/features/ObjectApi.java | 54 +++-
.../swift/v1/handlers/SwiftErrorHandler.java | 17 +-
.../v1/options/CreateContainerOptions.java | 1 +
.../swift/v1/reference/SwiftHeaders.java | 51 ++++
.../swift/v1/AuthenticationMockTest.java | 4 +-
.../swift/v1/TemporaryUrlSignerLiveTest.java | 2 +-
.../swift/v1/TemporaryUrlSignerMockTest.java | 8 +-
.../swift/v1/features/AccountApiLiveTest.java | 6 +-
.../swift/v1/features/AccountApiMockTest.java | 22 +-
.../swift/v1/features/BulkApiLiveTest.java | 12 +-
.../swift/v1/features/BulkApiMockTest.java | 4 +-
.../swift/v1/features/ContainerApiLiveTest.java | 16 +-
.../swift/v1/features/ContainerApiMockTest.java | 52 ++--
.../swift/v1/features/ObjectApiLiveTest.java | 91 +++++--
.../swift/v1/features/ObjectApiMockTest.java | 101 ++++++--
.../features/StaticLargeObjectApiLiveTest.java | 12 +-
.../features/StaticLargeObjectApiMockTest.java | 12 +-
.../swift/v1/internal/BaseSwiftApiLiveTest.java | 21 +-
openstack-swift/src/test/resources/access.json | 249 +++++++++++++++++++
20 files changed, 657 insertions(+), 129 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/CopyObjectException.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/CopyObjectException.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/CopyObjectException.java
new file mode 100644
index 0000000..9258662
--- /dev/null
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/CopyObjectException.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.openstack.swift.v1;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.ResourceNotFoundException;
+
+/**
+ * Thrown when an object cannot be copied.
+ *
+ * @see {@link SwiftErrorHandler#handleError(HttpCommand, HttpResponse)}
+ *
+ * @author Everett Toews
+ * @author Jeremy Daggett
+ */
+public class CopyObjectException extends ResourceNotFoundException {
+
+ private String sourcePath;
+ private String destinationPath;
+
+ public CopyObjectException(String sourcePath, String destinationPath, String message) {
+ super(String.format("Either the source path '%s' or the destination path '%s' was not found. " +
+ "(message: %s)", sourcePath, destinationPath, message));
+ this.sourcePath = sourcePath;
+ this.destinationPath = destinationPath;
+ }
+
+ public String getSourcePath() {
+ return sourcePath;
+ }
+
+ public String getDestinationPath() {
+ return destinationPath;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java
index 14ce2f4..374bfa6 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java
@@ -17,6 +17,7 @@
package org.jclouds.openstack.swift.v1.features;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FROM;
import java.util.Map;
@@ -33,10 +34,12 @@ import javax.ws.rs.PathParam;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.blobstore.BlobStoreFallbacks.FalseOnContainerNotFound;
import org.jclouds.http.options.GetOptions;
import org.jclouds.io.Payload;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.swift.v1.CopyObjectException;
import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindObjectMetadataToHeaders;
import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindRemoveObjectMetadataToHeaders;
import org.jclouds.openstack.swift.v1.binders.SetPayload;
@@ -48,6 +51,7 @@ import org.jclouds.openstack.swift.v1.functions.ParseObjectListFromResponse;
import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
@@ -64,7 +68,10 @@ public interface ObjectApi {
/**
* Lists up to 10,000 objects.
*
- * @return a list of existing storage objects ordered by name or null.
+ * @param options
+ * options to control the output list.
+ *
+ * @return an {@link ObjectList} of {@link SwiftObject} ordered by name or null.
*/
@Named("ListObjects")
@GET
@@ -103,7 +110,7 @@ public interface ObjectApi {
*
* @param objectName
* corresponds to {@link SwiftObject#name()}.
- * @return the Object or null, if not found.
+ * @return the {@link SwiftObject} or null, if not found.
*
* @see <a
* href="http://docs.openstack.org/api/openstack-object-storage/1.0/content/retrieve-object-metadata.html">
@@ -140,18 +147,18 @@ public interface ObjectApi {
SwiftObject get(@PathParam("objectName") String objectName, GetOptions options);
/**
- * Creates or updates the Object metadata.
+ * Creates or updates the metadata for a {@link SwiftObject}.
*
* @param objectName
* corresponds to {@link SwiftObject#name()}.
* @param metadata
- * the Object metadata to create or update.
+ * the metadata to create or update.
*
* @see <a
* href="http://docs.openstack.org/api/openstack-object-storage/1.0/content/Update_Container_Metadata-d1e1900.html">
* Create or Update Object Metadata API</a>
*
- * @return <code>true</code> if the Object Metadata was successfully created
+ * @return {@code true} if the metadata was successfully created
* or updated, false if not.
*/
@Named("UpdateObjectMetadata")
@@ -162,15 +169,14 @@ public interface ObjectApi {
@BinderParam(BindObjectMetadataToHeaders.class) Map<String, String> metadata);
/**
- * Deletes Object metadata.
+ * Deletes the metadata from a {@link SwiftObject}.
*
* @param objectName
* corresponds to {@link SwiftObject#name()}.
* @param metadata
- * the Object metadata to delete.
+ * corresponds to {@link SwiftObject#metadata()}.
*
- * @return <code>true</code> if the Object Metadata was successfully deleted,
- * false if not.
+ * @return {@code true} if the metadata was successfully deleted, false if not.
*
* @see <a
* href="http://docs.openstack.org/api/openstack-object-storage/1.0/content/delete-object-metadata.html">
@@ -184,7 +190,7 @@ public interface ObjectApi {
@BinderParam(BindRemoveObjectMetadataToHeaders.class) Map<String, String> metadata);
/**
- * Deletes a object, if present.
+ * Deletes an object, if present.
*
* @param objectName
* corresponds to {@link SwiftObject#name()}.
@@ -197,4 +203,32 @@ public interface ObjectApi {
@Fallback(VoidOnNotFoundOr404.class)
@Path("/{objectName}")
void delete(@PathParam("objectName") String objectName);
+
+ /**
+ * Copies an object from one container to another. Please note that this
+ * is a server side copy.
+ *
+ * @param destinationObject
+ * the destination object name.
+ * @param sourceContainer
+ * the source container name.
+ * @param sourceObject
+ * the source object name.
+ * @return {@code true} if the object was successfully copied, false if not.
+ *
+ * @throws CopyObjectException if the source or destination container do not exist
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-object-storage/1.0/content/copy-object.html">
+ * Copy Object API</a>
+ */
+ @Named("CopyObject")
+ @PUT
+ @Path("/{destinationObject}")
+ @Headers(keys = OBJECT_COPY_FROM, values = "/{sourceContainer}/{sourceObject}")
+ @Fallback(FalseOnContainerNotFound.class)
+ boolean copy(@PathParam("destinationObject") String destinationObject,
+ @PathParam("sourceContainer") String sourceContainer,
+ @PathParam("sourceObject") String sourceObject);
+
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
index f94f4a8..2fe469e 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/handlers/SwiftErrorHandler.java
@@ -27,6 +27,8 @@ import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
+import org.jclouds.openstack.swift.v1.CopyObjectException;
+import org.jclouds.openstack.swift.v1.reference.SwiftHeaders;
import org.jclouds.rest.AuthorizationException;
// TODO: is there error spec someplace? let's type errors, etc.
@@ -49,10 +51,21 @@ public class SwiftErrorHandler implements HttpErrorHandler {
exception = new AuthorizationException(exception.getMessage(), exception);
break;
case 404:
- if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ Exception oldException = exception;
+ String sourcePath = command.getCurrentRequest().getFirstHeaderOrNull(SwiftHeaders.OBJECT_COPY_FROM);
+ if (sourcePath != null) {
+ // the path returned here is in the form "/v1/tenant-id/destContainer/destObject"
+ String path = command.getCurrentRequest().getEndpoint().getPath();
+ int startOfDestinationPath = path.lastIndexOf("/", path.lastIndexOf("/") - 1);
+ // get the "/destContainer/destObject" portion of the path
+ String destinationPath = path.substring(startOfDestinationPath);
+
+ exception = new CopyObjectException(sourcePath, destinationPath, message);
+ exception.initCause(oldException);
+ } else if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
String path = command.getCurrentRequest().getEndpoint().getPath();
Matcher matcher = CONTAINER_PATH.matcher(path);
- Exception oldException = exception;
+
if (matcher.find()) {
exception = new ContainerNotFoundException(matcher.group(1), message);
exception.initCause(oldException);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
index 46506bb..fc8f9c8 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/options/CreateContainerOptions.java
@@ -29,6 +29,7 @@ import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders;
* @see ContainerApi#createIfAbsent
*/
public class CreateContainerOptions extends BaseHttpRequestOptions {
+ public static final CreateContainerOptions NONE = new CreateContainerOptions();
/** corresponds to {@link Container#metadata()} */
public CreateContainerOptions metadata(Map<String, String> metadata) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
new file mode 100644
index 0000000..e0c9348
--- /dev/null
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/reference/SwiftHeaders.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.openstack.swift.v1.reference;
+
+/**
+ * Common headers in Swift.
+ *
+ * @author Jeremy Daggett
+ */
+public interface SwiftHeaders {
+
+ String USER_METADATA_PREFIX = "X-Object-Meta-";
+
+ String ACCOUNT_TEMPORARY_URL_KEY = "X-Account-Meta-Temp-Url-Key";
+ String ACCOUNT_BYTES_USED = "X-Account-Bytes-Used";
+ String ACCOUNT_CONTAINER_COUNT = "X-Account-Container-Count";
+
+ String CONTAINER_BYTES_USED = "X-Container-Bytes-Used";
+ String CONTAINER_OBJECT_COUNT = "X-Container-Object-Count";
+ String CONTAINER_METADATA_PREFIX = "X-Container-Meta-";
+ String CONTAINER_DELETE_METADATA_PREFIX = "X-Remove-Container-Meta-";
+
+ String CONTAINER_READ = "X-Container-Read";
+ String CONTAINER_WRITE = "X-Container-Write";
+
+ String CONTAINER_WEB_INDEX = "X-Container-Meta-Web-Index";
+ String CONTAINER_WEB_ERROR = "X-Container-Meta-Web-Error";
+ String CONTAINER_WEB_LISTINGS = "X-Container-Meta-Web-Listings";
+ String CONTAINER_WEB_LISTINGS_CSS = "X-Container-Meta-Web-Listings-CSS";
+
+ String OBJECT_COPY_FROM = "X-Copy-From";
+ String OBJECT_DELETE_AFTER = "X-Delete-After";
+ String OBJECT_DELETE_AT = "X-Delete-At";
+ /** Get the newest version of the object for GET and HEAD requests */
+ String OBJECT_NEWEST = "X-Newest";
+ String OBJECT_VERSIONS_LOCATION = "X-Versions-Location";
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/AuthenticationMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/AuthenticationMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/AuthenticationMockTest.java
index 0514684..93f387b 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/AuthenticationMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/AuthenticationMockTest.java
@@ -51,8 +51,8 @@ public class AuthenticationMockTest extends BaseOpenStackMockTest<SwiftApi> {
@Test(dataProvider = "jclouds.keystone.credential-type")
public void authenticateCredentialType(String credentialType, String expectedPost) throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse()));
try {
Properties overrides = new Properties();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
index f2ba78f..733563c 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerLiveTest.java
@@ -73,7 +73,7 @@ public class TemporaryUrlSignerLiveTest extends BaseSwiftApiLiveTest {
String key = UUID.randomUUID().toString();
for (String regionId : api.configuredRegions()) {
api.accountApiInRegion(regionId).updateTemporaryUrlKey(key);
- api.containerApiInRegion(regionId).createIfAbsent(containerName, new CreateContainerOptions());
+ api.containerApiInRegion(regionId).createIfAbsent(containerName, CreateContainerOptions.NONE);
api.objectApiInRegionForContainer(regionId, containerName) //
.replace(name, newStringPayload("swifty"), ImmutableMap.<String, String> of());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
index f7ebb7d..0f856ba 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TemporaryUrlSignerMockTest.java
@@ -35,8 +35,8 @@ public class TemporaryUrlSignerMockTest extends BaseOpenStackMockTest<SwiftApi>
public void whenAccountApiHasKey() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse().addHeader("X-Account-Meta-Temp-URL-Key", "mykey"));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse().addHeader("X-Account-Meta-Temp-URL-Key", "mykey")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -57,8 +57,8 @@ public class TemporaryUrlSignerMockTest extends BaseOpenStackMockTest<SwiftApi>
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = ".*returned a null temporaryUrlKey!")
public void whenAccountApiDoesntHaveKey() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse()));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
index a1b388e..31eff6e 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiLiveTest.java
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableMap;
public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
public void get() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
Account account = accountApi.get();
@@ -46,7 +46,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
}
public void updateMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
@@ -58,7 +58,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest {
}
public void deleteMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
AccountApi accountApi = api.accountApiInRegion(regionId);
Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
index 41dd1c7..2c5a9b2 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/AccountApiMockTest.java
@@ -22,9 +22,9 @@ import static org.testng.Assert.assertTrue;
import java.util.Map;
import java.util.Map.Entry;
-import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.Account;
+import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@@ -41,11 +41,11 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
/** upper-cases first char, and lower-cases rest!! **/
public void getKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse() //
// note silly casing
.addHeader("X-Account-Meta-Apiname", "swift") //
- .addHeader("X-Account-Meta-Apiversion", "v1.1"));
+ .addHeader("X-Account-Meta-Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -68,10 +68,10 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse() //
.addHeader("X-Account-Meta-ApiName", "swift") //
- .addHeader("X-Account-Meta-ApiVersion", "v1.1"));
+ .addHeader("X-Account-Meta-ApiVersion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -92,8 +92,8 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateTemporaryUrlKey() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse()));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -112,8 +112,8 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void deleteMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(accountResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(accountResponse()));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
index 70f5c2f..39341fd 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiLiveTest.java
@@ -49,7 +49,7 @@ public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
private String containerName = getClass().getSimpleName();
public void notPresentWhenDeleting() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
BulkDeleteResponse deleteResponse = api.bulkApiInRegion(regionId).bulkDelete(
ImmutableList.of(UUID.randomUUID().toString()));
assertEquals(deleteResponse.deleted(), 0);
@@ -59,7 +59,7 @@ public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
}
public void extractArchive() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ExtractArchiveResponse extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName,
Payloads.newPayload(tarGz), "tar.gz");
assertEquals(extractResponse.created(), OBJECT_COUNT);
@@ -76,7 +76,7 @@ public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
@Test(dependsOnMethods = "extractArchive")
public void bulkDelete() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
BulkDeleteResponse deleteResponse = api.bulkApiInRegion(regionId).bulkDelete(paths);
assertEquals(deleteResponse.deleted(), OBJECT_COUNT);
assertEquals(deleteResponse.notFound(), 0);
@@ -92,9 +92,9 @@ public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
@BeforeClass(groups = "live")
public void setup() {
super.setup();
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
boolean created = api.containerApiInRegion(regionId).createIfAbsent(containerName,
- new CreateContainerOptions());
+ CreateContainerOptions.NONE);
if (!created) {
deleteAllObjectsInContainer(regionId, containerName);
}
@@ -115,7 +115,7 @@ public class BulkApiLiveTest extends BaseSwiftApiLiveTest {
@Override
@AfterClass(groups = "live")
public void tearDown() {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
deleteAllObjectsInContainer(regionId, containerName);
api.containerApiInRegion(regionId).deleteIfEmpty(containerName);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
index d73e448..69ce5a1 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/BulkApiMockTest.java
@@ -47,8 +47,8 @@ public class BulkApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
byte[] tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}"));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
index 7a21b2c..e28ca8e 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java
@@ -44,7 +44,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
@Test
public void list() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
FluentIterable<Container> response = containerApi.listFirstPage();
assertNotNull(response);
@@ -57,7 +57,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
}
public void get() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
Container container = api.containerApiInRegion(regionId).get(name);
assertEquals(container.name(), name);
assertTrue(container.objectCount() == 0);
@@ -67,7 +67,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
public void listAt() throws Exception {
String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
Container container = api.containerApiInRegion(regionId).listAt(lexicographicallyBeforeName).get(0);
assertEquals(container.name(), name);
assertTrue(container.objectCount() == 0);
@@ -76,7 +76,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
}
public void updateMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
@@ -88,7 +88,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
}
public void deleteMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ContainerApi containerApi = api.containerApiInRegion(regionId);
Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
@@ -118,15 +118,15 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest {
@BeforeClass(groups = "live")
public void setup() {
super.setup();
- for (String regionId : api.configuredRegions()) {
- api.containerApiInRegion(regionId).createIfAbsent(name, new CreateContainerOptions());
+ for (String regionId : regions) {
+ api.containerApiInRegion(regionId).createIfAbsent(name, CreateContainerOptions.NONE);
}
}
@Override
@AfterClass(groups = "live")
public void tearDown() {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
api.containerApiInRegion(regionId).deleteIfEmpty(name);
}
super.tearDown();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
index 63f9d80..b52122d 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiMockTest.java
@@ -47,8 +47,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void listFirstPage() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setBody(containerList));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(containerList)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -74,8 +74,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void listAt() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setBody(containerList));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(containerList)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -101,12 +101,12 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void createIfAbsent() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(201));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
- assertTrue(api.containerApiInRegion("DFW").createIfAbsent("myContainer", new CreateContainerOptions()));
+ assertTrue(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
assertEquals(server.getRequestCount(), 2);
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
@@ -120,8 +120,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void createWithOptions() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(201));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -143,12 +143,12 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void alreadyCreated() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(202));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(202)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
- assertFalse(api.containerApiInRegion("DFW").createIfAbsent("myContainer", new CreateContainerOptions()));
+ assertFalse(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
assertEquals(server.getRequestCount(), 2);
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
@@ -163,11 +163,11 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
/** upper-cases first char, and lower-cases rest!! **/
public void getKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(containerResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(containerResponse() //
// note silly casing
.addHeader("X-Container-Meta-Apiname", "swift") //
- .addHeader("X-Container-Meta-Apiversion", "v1.1"));
+ .addHeader("X-Container-Meta-Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -190,10 +190,10 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(containerResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(containerResponse() //
.addHeader("X-Container-Meta-ApiName", "swift") //
- .addHeader("X-Container-Meta-ApiVersion", "v1.1"));
+ .addHeader("X-Container-Meta-ApiVersion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -214,8 +214,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void deleteMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(containerResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(containerResponse()));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -236,8 +236,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void deleteIfEmpty() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(204));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -255,8 +255,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void alreadyDeleted() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(404));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -275,8 +275,8 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
@Test(expectedExceptions = IllegalStateException.class)
public void deleteWhenNotEmpty() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(409));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(409)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
index cfc7192..4559983 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
@@ -32,11 +32,15 @@ import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.jclouds.http.options.GetOptions;
+import org.jclouds.io.Payload;
+import org.jclouds.io.Payloads;
+import org.jclouds.openstack.swift.v1.CopyObjectException;
import org.jclouds.openstack.swift.v1.domain.ObjectList;
import org.jclouds.openstack.swift.v1.domain.SwiftObject;
import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest;
import org.jclouds.openstack.swift.v1.options.CreateContainerOptions;
import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
+import org.jclouds.util.Strings2;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -48,13 +52,71 @@ import com.google.common.collect.ImmutableMap;
*/
@Test(groups = "live", testName = "ObjectApiLiveTest")
public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
-
private String name = getClass().getSimpleName();
private String containerName = getClass().getSimpleName() + "Container";
+
+ public void copyObject() throws Exception {
+ for (String regionId : regions) {
+ // source
+ String sourceContainer = "src" + containerName;
+ String sourceObject = "original.txt";
+ String badSource = "badSource";
+
+ // destination
+ String destinationContainer = "dest" + containerName;
+ String destinationObject = "copy.txt";
+ String destinationPath = "/" + destinationContainer + "/" + destinationObject;
+
+ String stringPayload = "Hello World";
+ Payload data = Payloads.newPayload(stringPayload);
+
+ ContainerApi containerApi = api.containerApiInRegion(regionId);
+
+ // create source and destination dirs
+ containerApi.createIfAbsent(sourceContainer, CreateContainerOptions.NONE);
+ containerApi.createIfAbsent(destinationContainer, CreateContainerOptions.NONE);
+
+ // get the api for this region and container
+ ObjectApi srcApi = api.objectApiInRegionForContainer(regionId, sourceContainer);
+ ObjectApi destApi = api.objectApiInRegionForContainer(regionId, destinationContainer);
+
+ // Create source object
+ assertNotNull(srcApi.replace(sourceObject, data, ImmutableMap.<String, String> of()));
+ SwiftObject object = srcApi.get(sourceObject, GetOptions.NONE);
+ checkObject(object);
+
+ // Create the destination object
+ assertNotNull(destApi.replace(destinationObject, data, ImmutableMap.<String, String> of()));
+ object = destApi.get(destinationObject, GetOptions.NONE);
+ checkObject(destApi.get(destinationObject, GetOptions.NONE));
+
+ // check the copy operation
+ assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObject));
+ assertNotNull(destApi.head(destinationObject));
+
+ // now get a real SwiftObject
+ SwiftObject destSwiftObject = destApi.get(destinationObject, GetOptions.NONE);
+ assertEquals(Strings2.toString(destSwiftObject.payload()), stringPayload);
+
+ // test exception thrown on bad source name
+ try {
+ destApi.copy(destinationObject, badSource, sourceObject);
+ fail("Expected CopyObjectException");
+ } catch (CopyObjectException e) {
+ assertEquals(e.getSourcePath(), "/" + badSource + "/" + sourceObject);
+ assertEquals(e.getDestinationPath(), destinationPath);
+ }
+
+ deleteAllObjectsInContainer(regionId, sourceContainer);
+ containerApi.deleteIfEmpty(sourceContainer);
+
+ deleteAllObjectsInContainer(regionId, destinationContainer);
+ containerApi.deleteIfEmpty(destinationContainer);
+ }
+ }
- @Test
public void list() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ObjectApi objectApi = api.objectApiInRegionForContainer(regionId, containerName);
ObjectList response = objectApi.list(new ListContainerOptions());
assertEquals(response.container(), api.containerApiInRegion(regionId).get(containerName));
@@ -75,7 +137,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
}
public void metadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).head(name);
assertEquals(object.name(), name);
checkObject(object);
@@ -84,7 +146,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
}
public void get() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).get(name, GetOptions.NONE);
assertEquals(object.name(), name);
checkObject(object);
@@ -93,7 +155,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
}
public void privateByDefault() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).head(name);
try {
object.uri().toURL().openStream();
@@ -104,7 +166,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
}
public void getOptions() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).get(name, tail(1));
assertEquals(object.name(), name);
checkObject(object);
@@ -114,7 +176,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
public void listOptions() throws Exception {
String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName)
.list(marker(lexicographicallyBeforeName)).get(0);
assertEquals(object.name(), name);
@@ -123,19 +185,17 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
}
public void updateMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ObjectApi objectApi = api.objectApiInRegionForContainer(regionId, containerName);
Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
-
assertTrue(objectApi.updateMetadata(name, meta));
-
containerHasMetadata(objectApi, name, meta);
}
}
public void deleteMetadata() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ObjectApi objectApi = api.objectApiInRegionForContainer(regionId, containerName);
Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
@@ -165,8 +225,8 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
@BeforeClass(groups = "live")
public void setup() {
super.setup();
- for (String regionId : api.configuredRegions()) {
- api.containerApiInRegion(regionId).createIfAbsent(containerName, new CreateContainerOptions());
+ for (String regionId : regions) {
+ api.containerApiInRegion(regionId).createIfAbsent(containerName, CreateContainerOptions.NONE);
api.objectApiInRegionForContainer(regionId, containerName).replace(name, newStringPayload("swifty"),
ImmutableMap.<String, String> of());
}
@@ -175,7 +235,8 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
@Override
@AfterClass(groups = "live")
public void tearDown() {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
+ deleteAllObjectsInContainer(regionId, containerName);
api.objectApiInRegionForContainer(regionId, containerName).delete(name);
api.containerApiInRegion(regionId).deleteIfEmpty(containerName);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
index d8dfb1e..7ceb21a 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
@@ -20,23 +20,35 @@ import static com.google.common.base.Charsets.US_ASCII;
import static com.google.common.net.HttpHeaders.RANGE;
import static org.jclouds.http.options.GetOptions.Builder.tail;
import static org.jclouds.io.Payloads.newStringPayload;
+import static org.jclouds.openstack.swift.v1.features.ContainerApiMockTest.containerResponse;
import static org.jclouds.openstack.swift.v1.options.ListContainerOptions.Builder.marker;
+import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FROM;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import static org.jclouds.openstack.swift.v1.features.ContainerApiMockTest.containerResponse;
+import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Map.Entry;
+import javax.inject.Named;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.jclouds.blobstore.BlobStoreFallbacks.FalseOnContainerNotFound;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
-import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
+import org.jclouds.openstack.swift.v1.CopyObjectException;
import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.ObjectList;
import org.jclouds.openstack.swift.v1.domain.SwiftObject;
import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
+import org.jclouds.openstack.swift.v1.reference.SwiftHeaders;
+import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
@@ -83,10 +95,10 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void list() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(containerResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(containerResponse() //
.addHeader("X-Container-Read", ".r:*,.rlistings") //
- .setBody(objectList));
+ .setBody(objectList)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -106,8 +118,8 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void listOptions() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(containerResponse().setBody(objectList));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(containerResponse().setBody(objectList)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -125,10 +137,10 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void replace() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse() //
.setResponseCode(201) //
- .addHeader("ETag", "d9f5eb4bba4e2f2f046e54611bc8196b"));
+ .addHeader("ETag", "d9f5eb4bba4e2f2f046e54611bc8196b")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -153,11 +165,11 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
/** upper-cases first char, and lower-cases rest!! **/
public void headKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(objectResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(objectResponse() //
// note silly casing
.addHeader("X-Object-Meta-Apiname", "swift") //
- .addHeader("X-Object-Meta-Apiversion", "v1.1"));
+ .addHeader("X-Object-Meta-Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -183,11 +195,11 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void get() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(objectResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(objectResponse() //
// note silly casing
.addHeader("X-Object-Meta-Apiname", "swift") //
- .addHeader("X-Object-Meta-Apiversion", "v1.1"));
+ .addHeader("X-Object-Meta-Apiversion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -216,10 +228,10 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void updateMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(objectResponse() //
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(objectResponse() //
.addHeader("X-Object-Meta-ApiName", "swift") //
- .addHeader("X-Object-Meta-ApiVersion", "v1.1"));
+ .addHeader("X-Object-Meta-ApiVersion", "v1.1")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -240,8 +252,8 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void deleteMetadata() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(objectResponse());
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(objectResponse()));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -262,8 +274,8 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void delete() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(204));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -281,8 +293,8 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
public void alreadyDeleted() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(404));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -297,7 +309,44 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
server.shutdown();
}
}
-
+
+ public void copyObject() throws Exception {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)
+ .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bar/foo.txt")));
+ try {
+ SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
+ assertTrue(api.objectApiInRegionForContainer("DFW", "foo")
+ .copy("bar.txt", "bar", "foo.txt"));
+
+ assertEquals(server.getRequestCount(), 2);
+ assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
+
+ RecordedRequest copyRequest = server.takeRequest();
+ assertEquals(copyRequest.getRequestLine(),
+ "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/foo/bar.txt HTTP/1.1");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = CopyObjectException.class)
+ public void copyObjectFail() throws InterruptedException, IOException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)
+ .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bogus/foo.txt")));
+
+ try {
+ SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
+ // the following line will throw the CopyObjectException
+ api.objectApiInRegionForContainer("DFW", "foo").copy("bar.txt", "bogus", "foo.txt");
+ } finally {
+ server.shutdown();
+ }
+ }
+
private static final Map<String, String> metadata = ImmutableMap.of("ApiName", "swift", "ApiVersion", "v1.1");
public static MockResponse objectResponse() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiLiveTest.java
index 36af318..eb08f76 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiLiveTest.java
@@ -45,13 +45,13 @@ public class StaticLargeObjectApiLiveTest extends BaseSwiftApiLiveTest {
private byte[] megOf2s;
public void notPresentWhenDeleting() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
api.staticLargeObjectApiInRegionForContainer(regionId, containerName).delete(UUID.randomUUID().toString());
}
}
public void replaceManifest() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
ObjectApi objectApi = api.objectApiInRegionForContainer(regionId, containerName);
String etag1s = objectApi.replace(name + "/1", newPayload(megOf1s), ImmutableMap.<String, String> of());
assertMegabyteAndETagMatches(regionId, name + "/1", etag1s);
@@ -85,7 +85,7 @@ public class StaticLargeObjectApiLiveTest extends BaseSwiftApiLiveTest {
@Test(dependsOnMethods = "replaceManifest")
public void delete() throws Exception {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
api.staticLargeObjectApiInRegionForContainer(regionId, containerName).delete(name);
assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), 0);
}
@@ -95,9 +95,9 @@ public class StaticLargeObjectApiLiveTest extends BaseSwiftApiLiveTest {
@BeforeClass(groups = "live")
public void setup() {
super.setup();
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
boolean created = api.containerApiInRegion(regionId).createIfAbsent(containerName,
- new CreateContainerOptions());
+ CreateContainerOptions.NONE);
if (!created) {
deleteAllObjectsInContainer(regionId, containerName);
}
@@ -113,7 +113,7 @@ public class StaticLargeObjectApiLiveTest extends BaseSwiftApiLiveTest {
@Override
@AfterClass(groups = "live")
public void tearDown() {
- for (String regionId : api.configuredRegions()) {
+ for (String regionId : regions) {
deleteAllObjectsInContainer(regionId, containerName);
api.containerApiInRegion(regionId).deleteIfEmpty(containerName);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiMockTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiMockTest.java
index 529d7be..4da10a9 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiMockTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApiMockTest.java
@@ -35,8 +35,8 @@ public class StaticLargeObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi
public void replaceManifest() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().addHeader(HttpHeaders.ETAG, "\"abcd\""));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().addHeader(HttpHeaders.ETAG, "\"abcd\"")));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -71,8 +71,8 @@ public class StaticLargeObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi
public void delete() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(204));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
@@ -90,8 +90,8 @@ public class StaticLargeObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi
public void alreadyDeleted() throws Exception {
MockWebServer server = mockOpenStackServer();
- server.enqueue(new MockResponse().setBody(accessRackspace));
- server.enqueue(new MockResponse().setResponseCode(404));
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
try {
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java
index 8d8166e..239177c 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java
@@ -20,28 +20,47 @@ import static com.google.common.base.Preconditions.checkState;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.location.reference.LocationConstants;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.BulkDeleteResponse;
import org.jclouds.openstack.swift.v1.domain.ObjectList;
import org.jclouds.openstack.swift.v1.domain.SwiftObject;
import org.jclouds.openstack.swift.v1.options.ListContainerOptions;
+import org.testng.annotations.BeforeClass;
import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
public class BaseSwiftApiLiveTest extends BaseApiLiveTest<SwiftApi> {
+ protected Set<String> regions;
+
public BaseSwiftApiLiveTest() {
provider = "openstack-swift";
}
-
+
+ @Override
+ @BeforeClass(groups = "live")
+ public void setup() {
+ super.setup();
+ String providedRegion = System.getProperty("test." + LocationConstants.PROPERTY_REGION);
+ if (providedRegion != null) {
+ regions = ImmutableSet.of(providedRegion);
+ } else {
+ regions = api.configuredRegions();
+ }
+ }
+
@Override
protected Properties setupProperties() {
Properties props = super.setupProperties();
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ setIfTestSystemPropertyPresent(props, LocationConstants.PROPERTY_REGION);
return props;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0a8010be/openstack-swift/src/test/resources/access.json
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/resources/access.json b/openstack-swift/src/test/resources/access.json
new file mode 100644
index 0000000..8e0a69c
--- /dev/null
+++ b/openstack-swift/src/test/resources/access.json
@@ -0,0 +1,249 @@
+{
+ "access":{
+ "token":{
+ "id":"bb03a23aa8271291a7aaa9aaa2aaaaaa",
+ "expires":"2013-08-02T16:55:24.229-05:00",
+ "tenant":{
+ "id":"888888",
+ "name":"888888"
+ },
+ "RAX-AUTH:authenticatedBy":[
+ "PASSWORD"
+ ]
+ },
+ "serviceCatalog":[
+ {
+ "name":"cloudFilesCDN",
+ "endpoints":[
+ {
+ "region":"ORD",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ },
+ {
+ "region":"SYD",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ }
+ ],
+ "type":"rax:object-cdn"
+ },
+ {
+ "name":"cloudFiles",
+ "endpoints":[
+ {
+ "region":"ORD",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "internalURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "internalURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ },
+ {
+ "region":"SYD",
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "internalURL":"URL/v1\/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9"
+ }
+ ],
+ "type":"object-store"
+ },
+ {
+ "name":"cloudLoadBalancers",
+ "endpoints":[
+ {
+ "region":"SYD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ },
+ {
+ "region":"ORD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ }
+ ],
+ "type":"rax:load-balancer"
+ },
+ {
+ "name":"cloudDatabases",
+ "endpoints":[
+ {
+ "region":"SYD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ },
+ {
+ "region":"ORD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ }
+ ],
+ "type":"rax:database"
+ },
+ {
+ "name":"cloudBlockStorage",
+ "endpoints":[
+ {
+ "region":"SYD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1\/888888"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"888888",
+ "publicURL":"URL/v1\/888888"
+ },
+ {
+ "region":"ORD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1\/888888"
+ }
+ ],
+ "type":"volume"
+ },
+ {
+ "name":"cloudServersOpenStack",
+ "endpoints":[
+ {
+ "region":"SYD",
+ "tenantId":"888888",
+ "publicURL":"URL/v2\/888888",
+ "versionInfo":"https:\/\/syd.servers.api.rackspacecloud.com\/v2",
+ "versionList":"https:\/\/syd.servers.api.rackspacecloud.com\/",
+ "versionId":"2"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"888888",
+ "publicURL":"URL/v2\/888888",
+ "versionInfo":"https:\/\/dfw.servers.api.rackspacecloud.com\/v2",
+ "versionList":"https:\/\/dfw.servers.api.rackspacecloud.com\/",
+ "versionId":"2"
+ },
+ {
+ "region":"ORD",
+ "tenantId":"888888",
+ "publicURL":"URL/v2\/888888",
+ "versionInfo":"https:\/\/ord.servers.api.rackspacecloud.com\/v2",
+ "versionList":"https:\/\/ord.servers.api.rackspacecloud.com\/",
+ "versionId":"2"
+ }
+ ],
+ "type":"compute"
+ },
+ {
+ "name":"autoscale",
+ "endpoints":[
+ {
+ "region":"ORD",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888",
+ "versionInfo":null,
+ "versionList":null,
+ "versionId":"1.0"
+ },
+ {
+ "region":"DFW",
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888",
+ "versionInfo":null,
+ "versionList":null,
+ "versionId":"1.0"
+ }
+ ],
+ "type":"rax:autoscale"
+ },
+ {
+ "name":"cloudMonitoring",
+ "endpoints":[
+ {
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ }
+ ],
+ "type":"rax:monitor"
+ },
+ {
+ "name":"cloudBackup",
+ "endpoints":[
+ {
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ }
+ ],
+ "type":"rax:backup"
+ },
+ {
+ "name":"cloudServers",
+ "endpoints":[
+ {
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888",
+ "versionInfo":"https:\/\/servers.api.rackspacecloud.com\/v1.0",
+ "versionList":"https:\/\/servers.api.rackspacecloud.com\/",
+ "versionId":"1.0"
+ }
+ ],
+ "type":"compute"
+ },
+ {
+ "name":"cloudDNS",
+ "endpoints":[
+ {
+ "tenantId":"888888",
+ "publicURL":"URL/v1.0\/888888"
+ }
+ ],
+ "type":"rax:dns"
+ }
+ ],
+ "user":{
+ "id":"335853",
+ "roles":[
+ {
+ "id":"10000150",
+ "description":"Checkmate Access role",
+ "name":"checkmate"
+ },
+ {
+ "tenantId":"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9",
+ "id":"5",
+ "description":"A Role that allows a user access to keystone Service methods",
+ "name":"object-store:default"
+ },
+ {
+ "tenantId":"888888",
+ "id":"6",
+ "description":"A Role that allows a user access to keystone Service methods",
+ "name":"compute:default"
+ },
+ {
+ "id":"3",
+ "description":"User Admin Role.",
+ "name":"identity:user-admin"
+ }
+ ],
+ "name":"test",
+ "RAX-AUTH:defaultRegion":"ORD"
+ }
+ }
+}
[2/3] git commit: Renames multiple domain classes for consistency
Posted by za...@apache.org.
Renames multiple domain classes for consistency
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/commit/4f2fddbb
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/tree/4f2fddbb
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/diff/4f2fddbb
Branch: refs/heads/1.7.x
Commit: 4f2fddbbf1182213cf706401cc8da8c3e9e78d96
Parents: 24a37bd
Author: Zack Shoylev <za...@rackspace.com>
Authored: Tue Jan 7 16:25:26 2014 -0600
Committer: Zack Shoylev <za...@rackspace.com>
Committed: Thu Jan 16 15:44:46 2014 -0600
----------------------------------------------------------------------
.../v1/binders/BindScalingPolicyToJson.java | 4 +-
.../v1/binders/BindWebhooksToJson.java | 4 +-
.../v1/domain/CreateScalingPolicy.java | 396 +++++++++++++++++++
.../autoscale/v1/domain/CreateWebhook.java | 134 +++++++
.../rackspace/autoscale/v1/domain/Group.java | 12 +-
.../autoscale/v1/domain/ScalingPolicy.java | 361 ++---------------
.../v1/domain/ScalingPolicyResponse.java | 91 -----
.../rackspace/autoscale/v1/domain/Webhook.java | 126 +++---
.../autoscale/v1/domain/WebhookResponse.java | 106 -----
.../autoscale/v1/features/GroupApi.java | 6 +-
.../autoscale/v1/features/PolicyApi.java | 22 +-
.../autoscale/v1/features/WebhookApi.java | 34 +-
.../v1/functions/ParseGroupResponse.java | 12 +-
.../functions/ParseScalingPoliciesResponse.java | 16 +-
.../functions/ParseScalingPolicyResponse.java | 14 +-
.../autoscale/v1/internal/ParseHelper.java | 10 +-
.../autoscale/v1/utils/AutoscaleUtils.java | 4 +-
.../autoscale/v1/features/GroupApiLiveTest.java | 10 +-
.../autoscale/v1/features/GroupApiMockTest.java | 14 +-
.../v1/features/ScalingPolicyApiLiveTest.java | 66 ++--
.../v1/features/ScalingPolicyApiMockTest.java | 44 +--
.../v1/features/WebhookApiLiveTest.java | 42 +-
.../v1/features/WebhookApiMockTest.java | 26 +-
23 files changed, 777 insertions(+), 777 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindScalingPolicyToJson.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindScalingPolicyToJson.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindScalingPolicyToJson.java
index ec77508..2a598c1 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindScalingPolicyToJson.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindScalingPolicyToJson.java
@@ -19,7 +19,7 @@ package org.jclouds.rackspace.autoscale.v1.binders;
import java.util.Map;
import org.jclouds.http.HttpRequest;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
import org.jclouds.rackspace.autoscale.v1.internal.ParseHelper;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
@@ -41,7 +41,7 @@ public class BindScalingPolicyToJson implements MapBinder {
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- ScalingPolicy scalingPolicy = (ScalingPolicy) postParams.get("scalingPolicy");
+ CreateScalingPolicy scalingPolicy = (CreateScalingPolicy) postParams.get("scalingPolicy");
return jsonBinder.bindToRequest(request, ParseHelper.buildScalingPolicyMap(scalingPolicy));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java
index 2185b67..6fd9904 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/binders/BindWebhooksToJson.java
@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
import org.jclouds.http.HttpRequest;
-import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateWebhook;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
@@ -47,7 +47,7 @@ public class BindWebhooksToJson implements MapBinder {
// Refactoring will depend on whether this call will change any further.
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
ImmutableList.Builder<Map<String, Object>> webhookListBuilder = ImmutableList.builder();
- for(Webhook webhook : (List<Webhook>)postParams.get("webhooks") ) {
+ for(CreateWebhook webhook : (List<CreateWebhook>)postParams.get("webhooks") ) {
ImmutableMap.Builder<String, Object> webhookMap = ImmutableMap.builder();
webhookMap.put("name", webhook.getName());
if(!webhook.getMetadata().isEmpty()) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateScalingPolicy.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateScalingPolicy.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateScalingPolicy.java
new file mode 100644
index 0000000..33e824b
--- /dev/null
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateScalingPolicy.java
@@ -0,0 +1,396 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.rackspace.autoscale.v1.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.EnumSet;
+import java.util.Map;
+
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * Auto Scale ScalingPolicy. This class is used for requests.
+ *
+ * @see GroupApi#create(GroupConfiguration, LaunchConfiguration, java.util.List)
+ * @see Group#getScalingPolicies()
+ * @see ScalingPolicy
+ * @author Zack Shoylev
+ */
+public class CreateScalingPolicy implements Comparable<CreateScalingPolicy> {
+ private final String name;
+ private final ScalingPolicyType type;
+ private final int cooldown;
+ private final String target;
+ private final ScalingPolicyTargetType targetType;
+ private final Map<String, String> args;
+
+ @ConstructorProperties({
+ "name", "type", "cooldown", "target", "targetType", "args"
+ })
+ protected CreateScalingPolicy(String name, ScalingPolicyType type, int cooldown, String target, ScalingPolicyTargetType targetType, Map<String, String> args) {
+ this.name = checkNotNull(name, "name required");
+ this.type = type;
+ checkArgument(cooldown >= 0, "cooldown should be non-negative");
+ this.cooldown = cooldown;
+ this.target = target;
+ this.targetType = targetType;
+ this.args = args;
+ }
+
+ /**
+ * @return the name of this ScalingPolicy.
+ * @see CreateScalingPolicy.Builder#name(String)
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the type for this ScalingPolicy.
+ * @see ScalingPolicyType
+ * @see CreateScalingPolicy.Builder#type(String)
+ */
+ public ScalingPolicyType getType() {
+ return this.type;
+ }
+
+ /**
+ * @return the cooldown for this ScalingPolicy.
+ * @see CreateScalingPolicy.Builder#cooldown(int)
+ */
+ public int getCooldown() {
+ return this.cooldown;
+ }
+
+ /**
+ * @return the target for this ScalingPolicy. This is a numeric value, but could represent a 0-100% for some target types. Scale-down policies might have negative values.
+ *
+ * @see CreateScalingPolicy.Builder#target(int)
+ */
+ public String getTarget() {
+ return this.target;
+ }
+
+ /**
+ * @return the target type for this ScalingPolicy.
+ * @see ScalingPolicyTargetType
+ * @see CreateScalingPolicy.Builder#targetType(int)
+ */
+ public ScalingPolicyTargetType getTargetType() {
+ return this.targetType;
+ }
+
+ /**
+ * @return The scheduling string, if any.
+ * @see CreateScalingPolicy.Builder#atSchedule(String)
+ * @see CreateScalingPolicy.Builder#cronSchedule(String)
+ */
+ protected Map<String, String> getSchedulingArgs() {
+ return this.args;
+ }
+
+ /**
+ * @return The scheduling string, if any.
+ * @see CreateScalingPolicy.Builder#atSchedule(String)
+ * @see CreateScalingPolicy.Builder#cronSchedule(String)
+ */
+ public String getSchedulingString() {
+ if (this.args != null) {
+ for (Map.Entry<String, String> entry : this.args.entrySet()) {
+ return entry.getValue();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return The type of the schedule this policy uses.
+ */
+ public ScalingPolicyScheduleType getSchedulingType() {
+ if(this.args != null) {
+ for (ScalingPolicyScheduleType type : ScalingPolicyScheduleType.values()) {
+ if (this.args.get(type.toString()) != null) {
+ return type;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, type, cooldown, target, targetType, args);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ CreateScalingPolicy that = CreateScalingPolicy.class.cast(obj);
+ return Objects.equal(this.name, that.name) &&
+ Objects.equal(this.type, that.type) &&
+ Objects.equal(this.cooldown, that.cooldown) &&
+ Objects.equal(this.target, that.target) &&
+ Objects.equal(this.targetType, that.targetType) &&
+ Objects.equal(this.args, that.args);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name)
+ .add("type", type)
+ .add("cooldown", cooldown)
+ .add("target", target)
+ .add("targetType", targetType)
+ .add("args", args);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromScalingPolicy(this);
+ }
+
+ public static class Builder {
+ protected String name;
+ protected ScalingPolicyType type;
+ protected int cooldown;
+ protected String target;
+ protected ScalingPolicyTargetType targetType;
+ protected Map<String, String> args;
+
+ /**
+ * @param name The name of this ScalingPolicy.
+ * @return The builder object.
+ * @see CreateScalingPolicy#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @param type The type for this ScalingPolicy.
+ * @return The builder object.
+ * @see ScalingPolicyType
+ * @see CreateScalingPolicy#getType()
+ */
+ public Builder type(ScalingPolicyType type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * @param cooldown The cooldown of this ScalingPolicy.
+ * @return The builder object.
+ * @see CreateScalingPolicy#getCooldown()
+ */
+ public Builder cooldown(int cooldown) {
+ this.cooldown = cooldown;
+ return this;
+ }
+
+ /**
+ * @param target The target of this ScalingPolicy.
+ * @return The builder object.
+ * @see CreateScalingPolicy#getTarget()
+ */
+ public Builder target(String target) {
+ this.target = target;
+ return this;
+ }
+
+ /**
+ * @param targetType The target type of this ScalingPolicy.
+ * @return The builder object.
+ * @see ScalingPolicyTargetType
+ * @see CreateScalingPolicy#getTargetType()
+ */
+ public Builder targetType(ScalingPolicyTargetType targetType) {
+ this.targetType = targetType;
+ return this;
+ }
+
+ /**
+ * @param cron This parameter specifies the recurring time when the policy will be executed as a cron entry.
+ * For example, if this is parameter is set to "1 0 * * *",
+ * the policy will be executed at one minute past midnight (00:01)
+ * every day of the month, and every day of the week.
+ * You can either provide "cron" or "at" for a given policy, but not both.
+ * @return The builder object.
+ * @see ScalingPolicyTargetType
+ * @see CreateScalingPolicy#getTargetType()
+ * @see <a href="http://en.wikipedia.org/wiki/Cron">Cron</a>
+ */
+ public Builder cronSchedule(String cron) {
+ this.type = ScalingPolicyType.SCHEDULE;
+ this.args = ImmutableMap.of("cron", cron);
+ return this;
+ }
+
+ /**
+ * @param at This parameter specifies the time at which this policy will be executed.
+ * This property is mutually exclusive with the "cron" parameter.
+ * You can either provide "cron" or "at" for a given policy, but not both.
+ * Example date string: "2013-12-05T03:12:00Z"
+ * @return The builder object.
+ * @see ScalingPolicyTargetType
+ * @see CreateScalingPolicy#getTargetType()
+ */
+ public Builder atSchedule(String at) {
+ this.type = ScalingPolicyType.SCHEDULE;
+ this.args = ImmutableMap.of("at", at);
+ return this;
+ }
+
+ private Builder scheduleArgs(Map<String, String> args) {
+ this.args = args;
+ return this;
+ }
+
+ /**
+ * @return A new ScalingPolicy object.
+ */
+ public CreateScalingPolicy build() {
+ return new CreateScalingPolicy(name, type, cooldown, target, targetType, args);
+ }
+
+ /**
+ * @param in The target scaling policy
+ * @return The scaling policy builder
+ */
+ public Builder fromScalingPolicy(CreateScalingPolicy in) {
+ return this
+ .name(in.getName())
+ .type(in.getType())
+ .cooldown(in.getCooldown())
+ .target(in.getTarget())
+ .targetType(in.getTargetType())
+ .scheduleArgs(in.getSchedulingArgs());
+ }
+ }
+
+ @Override
+ public int compareTo(CreateScalingPolicy that) {
+ return this.getName().compareTo(that.getName());
+ }
+
+ /**
+ * Enumerates different types of scaling policies
+ */
+ public static enum ScalingPolicyType {
+ WEBHOOK("webhook"),
+ SCHEDULE("schedule");
+
+ private final String name;
+
+ private ScalingPolicyType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public static Optional<ScalingPolicyType> getByValue(String value){
+ for (final ScalingPolicyType element : EnumSet.allOf(ScalingPolicyType.class)) {
+ if (element.toString().equals(value)) {
+ return Optional.of(element);
+ }
+ }
+ return Optional.absent();
+ }
+ }
+
+ /**
+ * Enumerates different types of targets a policy might have
+ */
+ public static enum ScalingPolicyTargetType {
+ INCREMENTAL("change"),
+ DESIRED_CAPACITY("desiredCapacity"),
+ PERCENT_CHANGE("changePercent");
+
+ private final String name;
+
+ private ScalingPolicyTargetType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public static Optional<ScalingPolicyTargetType> getByValue(String value){
+ for (final ScalingPolicyTargetType element : EnumSet.allOf(ScalingPolicyTargetType.class)) {
+ if (element.toString().equals(value)) {
+ return Optional.of(element);
+ }
+ }
+ return Optional.absent();
+ }
+ }
+
+ /**
+ * Enumerates different types of targets a policy might have
+ */
+ public static enum ScalingPolicyScheduleType {
+ /**
+ * Example: "1 0 * * *"
+ * @see ScalingPolicy.Builder#cronSchedule(String)
+ */
+ AT("at"),
+ /**
+ * Example date string: "2013-12-05T03:12:00Z"
+ * @see ScalingPolicy.Builder#atSchedule(String)
+ */
+ CRON("cron");
+
+ private final String name;
+
+ private ScalingPolicyScheduleType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public static Optional<ScalingPolicyTargetType> getByValue(String value){
+ for (final ScalingPolicyTargetType element : EnumSet.allOf(ScalingPolicyTargetType.class)) {
+ if (element.toString().equals(value)) {
+ return Optional.of(element);
+ }
+ }
+ return Optional.absent();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateWebhook.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateWebhook.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateWebhook.java
new file mode 100644
index 0000000..4e6ae12
--- /dev/null
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/CreateWebhook.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.rackspace.autoscale.v1.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * An Autoscale Webhook for a specific group and policy.
+ *
+ * @see Group
+ * @see CreateScalingPolicy
+ * @author Zack Shoylev
+ */
+public class CreateWebhook {
+ private final String name;
+ private final ImmutableMap<String, Object> metadata;
+
+ @ConstructorProperties({ "name", "metadata" })
+ protected CreateWebhook(String name, @Nullable Map<String, Object> metadata) {
+ this.name = checkNotNull(name, "name should not be null");
+ if (metadata == null) {
+ this.metadata = ImmutableMap.of();
+ } else {
+ this.metadata = ImmutableMap.copyOf(metadata);
+ }
+ }
+
+ /**
+ * @return the name of this Webhook.
+ * @see CreateWebhook.Builder#name(String)
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the metadata for this Webhook.
+ * @see CreateWebhook.Builder#metadata(Map)
+ */
+ public ImmutableMap<String, Object> getMetadata() {
+ return this.metadata;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, metadata);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ CreateWebhook that = CreateWebhook.class.cast(obj);
+ return Objects.equal(this.name, that.name) && Objects.equal(this.metadata, that.metadata);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this).add("name", name).add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromWebhook(this);
+ }
+
+ public static class Builder {
+ protected String name;
+ protected Map<String, Object> metadata;
+
+ /**
+ * @param name The name of this Webhook.
+ * @return The builder object.
+ * @see CreateWebhook#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @param metadata The metadata of this Webhook.
+ * @return The builder object.
+ * @see CreateWebhook#getMetadata()
+ */
+ public Builder metadata(Map<String, Object> metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * @return A new Webhook object.
+ */
+ public CreateWebhook build() {
+ return new CreateWebhook(name, metadata);
+ }
+
+ public Builder fromWebhook(CreateWebhook in) {
+ return this.name(in.getName()).metadata(in.getMetadata());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Group.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Group.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Group.java
index 091143c..b079a91 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Group.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Group.java
@@ -34,11 +34,11 @@ import com.google.common.collect.ImmutableList;
public class Group {
private final String id;
private final ImmutableList<Link> links;
- private final ImmutableList<ScalingPolicyResponse> scalingPolicy;
+ private final ImmutableList<ScalingPolicy> scalingPolicy;
private final GroupConfiguration groupConfiguration;
private final LaunchConfiguration launchConfiguration;
- protected Group(String id, ImmutableList<Link> links, ImmutableList<ScalingPolicyResponse> scalingPolicy, GroupConfiguration groupConfiguration, LaunchConfiguration launchConfiguration) {
+ protected Group(String id, ImmutableList<Link> links, ImmutableList<ScalingPolicy> scalingPolicy, GroupConfiguration groupConfiguration, LaunchConfiguration launchConfiguration) {
this.id = id;
this.links = links;
this.scalingPolicy = scalingPolicy;
@@ -66,10 +66,10 @@ public class Group {
/**
* @return A list of scaling policies for this Group.
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
* @see Group.Builder#scalingPolicy(List)
*/
- public ImmutableList<ScalingPolicyResponse> getScalingPolicies() {
+ public ImmutableList<ScalingPolicy> getScalingPolicies() {
return this.scalingPolicy;
}
@@ -133,7 +133,7 @@ public class Group {
public static class Builder {
protected String id;
protected ImmutableList<Link> links;
- protected ImmutableList<ScalingPolicyResponse> scalingPolicy;
+ protected ImmutableList<ScalingPolicy> scalingPolicy;
protected GroupConfiguration groupConfiguration;
protected LaunchConfiguration launchConfiguration;
@@ -162,7 +162,7 @@ public class Group {
* @return The builder object.
* @see Group#getScalingPolicy()
*/
- public Builder scalingPolicy(List<ScalingPolicyResponse> scalingPolicy) {
+ public Builder scalingPolicy(List<ScalingPolicy> scalingPolicy) {
this.scalingPolicy = ImmutableList.copyOf(scalingPolicy);
return this;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicy.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicy.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicy.java
index 6420ee3..acbf634 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicy.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicy.java
@@ -16,132 +16,56 @@
*/
package org.jclouds.rackspace.autoscale.v1.domain;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
-import java.util.EnumSet;
+import java.util.List;
import java.util.Map;
+import org.jclouds.openstack.v2_0.domain.Link;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableList;
/**
- * Auto Scale ScalingPolicy. This class is used for requests.
+ * Autoscale ScalingPolicyResponse. Extends ScalingPolicy with id and links.
*
- * @see GroupApi#create(GroupConfiguration, LaunchConfiguration, java.util.List)
* @see Group#getScalingPolicies()
- * @see ScalingPolicyResponse
* @author Zack Shoylev
*/
-public class ScalingPolicy implements Comparable<ScalingPolicy>{
- private final String name;
- private final ScalingPolicyType type;
- private final int cooldown;
- private final String target;
- private final ScalingPolicyTargetType targetType;
- private final Map<String, String> args;
+public class ScalingPolicy extends CreateScalingPolicy{
+ private final ImmutableList<Link> links;
+ private final String id;
@ConstructorProperties({
- "name", "type", "cooldown", "target", "targetType", "args"
+ "name", "type", "cooldown", "target", "targetType", "args", "links", "id"
})
- protected ScalingPolicy(String name, ScalingPolicyType type, int cooldown, String target, ScalingPolicyTargetType targetType, Map<String, String> args) {
- this.name = checkNotNull(name, "name required");
- this.type = type;
- checkArgument(cooldown >= 0, "cooldown should be non-negative");
- this.cooldown = cooldown;
- this.target = target;
- this.targetType = targetType;
- this.args = args;
+ public ScalingPolicy(String name, ScalingPolicyType type, int cooldown, String target, ScalingPolicyTargetType targetType, Map<String, String> args, List<Link> links, String id) {
+ super(name, type, cooldown, target, targetType, args);
+ this.id = checkNotNull(id, "id required");
+ this.links = ImmutableList.copyOf(checkNotNull(links, "links required"));
}
/**
- * @return the name of this ScalingPolicy.
- * @see ScalingPolicy.Builder#name(String)
+ * @return the unique id of this ScalingPolicy.
+ * @see ScalingPolicyResponse.Builder#id(String)
*/
- public String getName() {
- return this.name;
+ public String getId() {
+ return this.id;
}
/**
- * @return the type for this ScalingPolicy.
- * @see ScalingPolicyType
- * @see ScalingPolicy.Builder#type(String)
+ * @return the links to this ScalingPolicy.
+ * @see ScalingPolicyResponse.Builder#links(String)
*/
- public ScalingPolicyType getType() {
- return this.type;
- }
-
- /**
- * @return the cooldown for this ScalingPolicy.
- * @see ScalingPolicy.Builder#cooldown(int)
- */
- public int getCooldown() {
- return this.cooldown;
- }
-
- /**
- * @return the target for this ScalingPolicy. This is a numeric value, but could represent a 0-100% for some target types. Scale-down policies might have negative values.
- *
- * @see ScalingPolicy.Builder#target(int)
- */
- public String getTarget() {
- return this.target;
- }
-
- /**
- * @return the target type for this ScalingPolicy.
- * @see ScalingPolicyTargetType
- * @see ScalingPolicy.Builder#targetType(int)
- */
- public ScalingPolicyTargetType getTargetType() {
- return this.targetType;
- }
-
- /**
- * @return The scheduling string, if any.
- * @see ScalingPolicy.Builder#atSchedule(String)
- * @see ScalingPolicy.Builder#cronSchedule(String)
- */
- protected Map<String, String> getSchedulingArgs() {
- return this.args;
- }
-
- /**
- * @return The scheduling string, if any.
- * @see ScalingPolicy.Builder#atSchedule(String)
- * @see ScalingPolicy.Builder#cronSchedule(String)
- */
- public String getSchedulingString() {
- if (this.args != null) {
- for (Map.Entry<String, String> entry : this.args.entrySet()) {
- return entry.getValue();
- }
- }
- return null;
- }
-
- /**
- * @return The type of the schedule this policy uses.
- */
- public ScalingPolicyScheduleType getSchedulingType() {
- if(this.args != null) {
- for (ScalingPolicyScheduleType type : ScalingPolicyScheduleType.values()) {
- if (this.args.get(type.toString()) != null) {
- return type;
- }
- }
- }
- return null;
+ public ImmutableList<Link> getLinks() {
+ return this.links;
}
@Override
public int hashCode() {
- return Objects.hashCode(name, type, cooldown, target, targetType, args);
+ return Objects.hashCode(super.hashCode(), links, id);
}
@Override
@@ -149,248 +73,19 @@ public class ScalingPolicy implements Comparable<ScalingPolicy>{
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
ScalingPolicy that = ScalingPolicy.class.cast(obj);
- return Objects.equal(this.name, that.name) &&
- Objects.equal(this.type, that.type) &&
- Objects.equal(this.cooldown, that.cooldown) &&
- Objects.equal(this.target, that.target) &&
- Objects.equal(this.targetType, that.targetType) &&
- Objects.equal(this.args, that.args);
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.links, that.links) &&
+ super.equals(obj);
}
protected ToStringHelper string() {
- return Objects.toStringHelper(this)
- .add("name", name)
- .add("type", type)
- .add("cooldown", cooldown)
- .add("target", target)
- .add("targetType", targetType)
- .add("args", args);
+ return super.string()
+ .add("links", links)
+ .add("id", id);
}
@Override
public String toString() {
return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromScalingPolicy(this);
- }
-
- public static class Builder {
- protected String name;
- protected ScalingPolicyType type;
- protected int cooldown;
- protected String target;
- protected ScalingPolicyTargetType targetType;
- protected Map<String, String> args;
-
- /**
- * @param name The name of this ScalingPolicy.
- * @return The builder object.
- * @see ScalingPolicy#getName()
- */
- public Builder name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * @param type The type for this ScalingPolicy.
- * @return The builder object.
- * @see ScalingPolicyType
- * @see ScalingPolicy#getType()
- */
- public Builder type(ScalingPolicyType type) {
- this.type = type;
- return this;
- }
-
- /**
- * @param cooldown The cooldown of this ScalingPolicy.
- * @return The builder object.
- * @see ScalingPolicy#getCooldown()
- */
- public Builder cooldown(int cooldown) {
- this.cooldown = cooldown;
- return this;
- }
-
- /**
- * @param target The target of this ScalingPolicy.
- * @return The builder object.
- * @see ScalingPolicy#getTarget()
- */
- public Builder target(String target) {
- this.target = target;
- return this;
- }
-
- /**
- * @param targetType The target type of this ScalingPolicy.
- * @return The builder object.
- * @see ScalingPolicyTargetType
- * @see ScalingPolicy#getTargetType()
- */
- public Builder targetType(ScalingPolicyTargetType targetType) {
- this.targetType = targetType;
- return this;
- }
-
- /**
- * @param cron This parameter specifies the recurring time when the policy will be executed as a cron entry.
- * For example, if this is parameter is set to "1 0 * * *",
- * the policy will be executed at one minute past midnight (00:01)
- * every day of the month, and every day of the week.
- * You can either provide "cron" or "at" for a given policy, but not both.
- * @return The builder object.
- * @see ScalingPolicyTargetType
- * @see ScalingPolicy#getTargetType()
- * @see <a href="http://en.wikipedia.org/wiki/Cron">Cron</a>
- */
- public Builder cronSchedule(String cron) {
- this.type = ScalingPolicyType.SCHEDULE;
- this.args = ImmutableMap.of("cron", cron);
- return this;
- }
-
- /**
- * @param at This parameter specifies the time at which this policy will be executed.
- * This property is mutually exclusive with the "cron" parameter.
- * You can either provide "cron" or "at" for a given policy, but not both.
- * Example date string: "2013-12-05T03:12:00Z"
- * @return The builder object.
- * @see ScalingPolicyTargetType
- * @see ScalingPolicy#getTargetType()
- */
- public Builder atSchedule(String at) {
- this.type = ScalingPolicyType.SCHEDULE;
- this.args = ImmutableMap.of("at", at);
- return this;
- }
-
- private Builder scheduleArgs(Map<String, String> args) {
- this.args = args;
- return this;
- }
-
- /**
- * @return A new ScalingPolicy object.
- */
- public ScalingPolicy build() {
- return new ScalingPolicy(name, type, cooldown, target, targetType, args);
- }
-
- /**
- * @param in The target scaling policy
- * @return The scaling policy builder
- */
- public Builder fromScalingPolicy(ScalingPolicy in) {
- return this
- .name(in.getName())
- .type(in.getType())
- .cooldown(in.getCooldown())
- .target(in.getTarget())
- .targetType(in.getTargetType())
- .scheduleArgs(in.getSchedulingArgs());
- }
- }
-
- @Override
- public int compareTo(ScalingPolicy that) {
- return this.getName().compareTo(that.getName());
- }
-
- /**
- * Enumerates different types of scaling policies
- */
- public static enum ScalingPolicyType {
- WEBHOOK("webhook"),
- SCHEDULE("schedule");
-
- private final String name;
-
- private ScalingPolicyType(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- public static Optional<ScalingPolicyType> getByValue(String value){
- for (final ScalingPolicyType element : EnumSet.allOf(ScalingPolicyType.class)) {
- if (element.toString().equals(value)) {
- return Optional.of(element);
- }
- }
- return Optional.absent();
- }
- }
-
- /**
- * Enumerates different types of targets a policy might have
- */
- public static enum ScalingPolicyTargetType {
- INCREMENTAL("change"),
- DESIRED_CAPACITY("desiredCapacity"),
- PERCENT_CHANGE("changePercent");
-
- private final String name;
-
- private ScalingPolicyTargetType(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- public static Optional<ScalingPolicyTargetType> getByValue(String value){
- for (final ScalingPolicyTargetType element : EnumSet.allOf(ScalingPolicyTargetType.class)) {
- if (element.toString().equals(value)) {
- return Optional.of(element);
- }
- }
- return Optional.absent();
- }
- }
-
- /**
- * Enumerates different types of targets a policy might have
- */
- public static enum ScalingPolicyScheduleType {
- /**
- * Example: "1 0 * * *"
- * @see ScalingPolicy.Builder#cronSchedule(String)
- */
- AT("at"),
- /**
- * Example date string: "2013-12-05T03:12:00Z"
- * @see ScalingPolicy.Builder#atSchedule(String)
- */
- CRON("cron");
-
- private final String name;
-
- private ScalingPolicyScheduleType(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- public static Optional<ScalingPolicyTargetType> getByValue(String value){
- for (final ScalingPolicyTargetType element : EnumSet.allOf(ScalingPolicyTargetType.class)) {
- if (element.toString().equals(value)) {
- return Optional.of(element);
- }
- }
- return Optional.absent();
- }
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicyResponse.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicyResponse.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicyResponse.java
deleted file mode 100644
index 0bf0302..0000000
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/ScalingPolicyResponse.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.rackspace.autoscale.v1.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.openstack.v2_0.domain.Link;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Autoscale ScalingPolicyResponse. Extends ScalingPolicy with id and links.
- *
- * @see Group#getScalingPolicies()
- * @author Zack Shoylev
- */
-public class ScalingPolicyResponse extends ScalingPolicy{
- private final ImmutableList<Link> links;
- private final String id;
-
- @ConstructorProperties({
- "name", "type", "cooldown", "target", "targetType", "args", "links", "id"
- })
- public ScalingPolicyResponse(String name, ScalingPolicyType type, int cooldown, String target, ScalingPolicyTargetType targetType, Map<String, String> args, List<Link> links, String id) {
- super(name, type, cooldown, target, targetType, args);
- this.id = checkNotNull(id, "id required");
- this.links = ImmutableList.copyOf(checkNotNull(links, "links required"));
- }
-
- /**
- * @return the unique id of this ScalingPolicy.
- * @see ScalingPolicyResponse.Builder#id(String)
- */
- public String getId() {
- return this.id;
- }
-
- /**
- * @return the links to this ScalingPolicy.
- * @see ScalingPolicyResponse.Builder#links(String)
- */
- public ImmutableList<Link> getLinks() {
- return this.links;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), links, id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- ScalingPolicyResponse that = ScalingPolicyResponse.class.cast(obj);
- return Objects.equal(this.id, that.id) &&
- Objects.equal(this.links, that.links) &&
- super.equals(obj);
- }
-
- protected ToStringHelper string() {
- return super.string()
- .add("links", links)
- .add("id", id);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java
index 76bff6f..07e8ab7 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/Webhook.java
@@ -19,116 +19,88 @@ package org.jclouds.rackspace.autoscale.v1.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.List;
import java.util.Map;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
/**
- * An Autoscale Webhook for a specific group and policy.
+ * Autoscale WebhookResponse. Extends Webhook with id and links.
*
- * @see Group
- * @see ScalingPolicy
+ * @see CreateWebhook#getWebhooks()
* @author Zack Shoylev
*/
-public class Webhook {
- private final String name;
- private final ImmutableMap<String, Object> metadata;
-
- @ConstructorProperties({ "name", "metadata" })
- protected Webhook(String name, @Nullable Map<String, Object> metadata) {
- this.name = checkNotNull(name, "name should not be null");
- if (metadata == null) {
- this.metadata = ImmutableMap.of();
- } else {
- this.metadata = ImmutableMap.copyOf(metadata);
- }
+public class Webhook extends CreateWebhook {
+ private final ImmutableList<Link> links;
+ private final String id;
+
+ @ConstructorProperties({
+ "name", "metadata", "links", "id"
+ })
+ public Webhook(String name, @Nullable Map<String, Object> metadata, List<Link> links, String id) {
+ super(name, metadata);
+ this.id = checkNotNull(id, "id required");
+ this.links = ImmutableList.copyOf(checkNotNull(links, "links required"));
}
/**
- * @return the name of this Webhook.
- * @see Webhook.Builder#name(String)
+ * @return the unique id of this ScalingPolicy.
+ * @see ScalingPolicyResponse.Builder#id(String)
*/
- public String getName() {
- return this.name;
- }
+ public String getId() {
+ return this.id;
+ }
/**
- * @return the metadata for this Webhook.
- * @see Webhook.Builder#metadata(Map)
+ * The capability Link for the webhook can be called with a POST request to execute the webhook anonymously.
+ * @return the links to this ScalingPolicy.
+ * @see ScalingPolicyResponse.Builder#links(String)
*/
- public ImmutableMap<String, Object> getMetadata() {
- return this.metadata;
+ public ImmutableList<Link> getLinks() {
+ return this.links;
+ }
+
+ public Optional<URI> getAnonymousExecutionURI() {
+ // TODO: Add Relation.CAPABILITY to openstack Link
+ for (Link l : this.links) {
+ if (l.getRelation() == Relation.UNRECOGNIZED) {
+ return Optional.of(l.getHref());
+ }
+ }
+ return Optional.absent();
}
@Override
public int hashCode() {
- return Objects.hashCode(name, metadata);
+ return Objects.hashCode(super.hashCode(), links, id);
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
Webhook that = Webhook.class.cast(obj);
- return Objects.equal(this.name, that.name) && Objects.equal(this.metadata, that.metadata);
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.links, that.links) &&
+ super.equals(obj);
}
protected ToStringHelper string() {
- return Objects.toStringHelper(this).add("name", name).add("metadata", metadata);
+ return super.string()
+ .add("links", links)
+ .add("id", id);
}
@Override
public String toString() {
return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromWebhook(this);
- }
-
- public static class Builder {
- protected String name;
- protected Map<String, Object> metadata;
-
- /**
- * @param name The name of this Webhook.
- * @return The builder object.
- * @see Webhook#getName()
- */
- public Builder name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * @param metadata The metadata of this Webhook.
- * @return The builder object.
- * @see Webhook#getMetadata()
- */
- public Builder metadata(Map<String, Object> metadata) {
- this.metadata = metadata;
- return this;
- }
-
- /**
- * @return A new Webhook object.
- */
- public Webhook build() {
- return new Webhook(name, metadata);
- }
-
- public Builder fromWebhook(Webhook in) {
- return this.name(in.getName()).metadata(in.getMetadata());
- }
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/WebhookResponse.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/WebhookResponse.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/WebhookResponse.java
deleted file mode 100644
index 8abe691..0000000
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/domain/WebhookResponse.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.rackspace.autoscale.v1.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.openstack.v2_0.domain.Link;
-import org.jclouds.openstack.v2_0.domain.Link.Relation;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Autoscale WebhookResponse. Extends Webhook with id and links.
- *
- * @see Webhook#getWebhooks()
- * @author Zack Shoylev
- */
-public class WebhookResponse extends Webhook{
- private final ImmutableList<Link> links;
- private final String id;
-
- @ConstructorProperties({
- "name", "metadata", "links", "id"
- })
- public WebhookResponse(String name, @Nullable Map<String, Object> metadata, List<Link> links, String id) {
- super(name, metadata);
- this.id = checkNotNull(id, "id required");
- this.links = ImmutableList.copyOf(checkNotNull(links, "links required"));
- }
-
- /**
- * @return the unique id of this ScalingPolicy.
- * @see ScalingPolicyResponse.Builder#id(String)
- */
- public String getId() {
- return this.id;
- }
-
- /**
- * The capability Link for the webhook can be called with a POST request to execute the webhook anonymously.
- * @return the links to this ScalingPolicy.
- * @see ScalingPolicyResponse.Builder#links(String)
- */
- public ImmutableList<Link> getLinks() {
- return this.links;
- }
-
- public Optional<URI> getAnonymousExecutionURI() {
- // TODO: Add Relation.CAPABILITY to openstack Link
- for (Link l : this.links) {
- if (l.getRelation() == Relation.UNRECOGNIZED) {
- return Optional.of(l.getHref());
- }
- }
- return Optional.absent();
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), links, id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- WebhookResponse that = WebhookResponse.class.cast(obj);
- return Objects.equal(this.id, that.id) &&
- Objects.equal(this.links, that.links) &&
- super.equals(obj);
- }
-
- protected ToStringHelper string() {
- return super.string()
- .add("links", links)
- .add("id", id);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/GroupApi.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/GroupApi.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/GroupApi.java
index c78f658..9b9cb48 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/GroupApi.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/GroupApi.java
@@ -39,7 +39,7 @@ import org.jclouds.rackspace.autoscale.v1.domain.Group;
import org.jclouds.rackspace.autoscale.v1.domain.GroupConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.GroupState;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
import org.jclouds.rackspace.autoscale.v1.functions.ParseGroupLaunchConfigurationResponse;
import org.jclouds.rackspace.autoscale.v1.functions.ParseGroupResponse;
import org.jclouds.rest.annotations.Fallback;
@@ -68,7 +68,7 @@ public interface GroupApi extends Closeable {
* @return Group The group created by this call.
* @see GroupConfiguration
* @see LaunchConfiguration
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
* @see Group
*/
@Named("Group:create")
@@ -79,7 +79,7 @@ public interface GroupApi extends Closeable {
@ResponseParser(ParseGroupResponse.class)
Group create(@PayloadParam("groupConfiguration") GroupConfiguration groupConfiguration,
@PayloadParam("launchConfiguration") LaunchConfiguration launchConfiguration,
- @PayloadParam("scalingPolicies") List<ScalingPolicy> scalingPolicies);
+ @PayloadParam("scalingPolicies") List<CreateScalingPolicy> scalingPolicies);
/**
* This operation pauses the specified Autoscaling Group
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/PolicyApi.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/PolicyApi.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/PolicyApi.java
index 2e3f2b1..7424a72 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/PolicyApi.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/PolicyApi.java
@@ -36,8 +36,8 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rackspace.autoscale.v1.binders.BindScalingPoliciesToJson;
import org.jclouds.rackspace.autoscale.v1.binders.BindScalingPolicyToJson;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
import org.jclouds.rackspace.autoscale.v1.functions.ParseScalingPoliciesResponse;
import org.jclouds.rackspace.autoscale.v1.functions.ParseScalingPolicyResponse;
import org.jclouds.rest.annotations.Fallback;
@@ -60,8 +60,8 @@ public interface PolicyApi extends Closeable {
* Create a scaling policy.
* @param scalingPolicies The list of scaling policies.
* @return List of the created scaling policies
+ * @see CreateScalingPolicy
* @see ScalingPolicy
- * @see ScalingPolicyResponse
*/
@Named("Policy:create")
@POST
@@ -69,48 +69,48 @@ public interface PolicyApi extends Closeable {
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@MapBinder(BindScalingPoliciesToJson.class)
@ResponseParser(ParseScalingPoliciesResponse.class)
- FluentIterable<ScalingPolicyResponse> create(@PayloadParam("scalingPolicies") List<ScalingPolicy> scalingPolicies);
+ FluentIterable<ScalingPolicy> create(@PayloadParam("scalingPolicies") List<CreateScalingPolicy> scalingPolicies);
/**
* This operation lists all scaling policies.
* @return A list of scaling policy responses.
- * @see ScalingPolicyResponse
+ * @see ScalingPolicy
*/
@Named("Policy:list")
@GET
@Path("/policies")
@ResponseParser(ParseScalingPoliciesResponse.class)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- FluentIterable<ScalingPolicyResponse> list();
+ FluentIterable<ScalingPolicy> list();
/**
* This operation returns the details for a single scaling policy.
* @return Existing scaling policy details
- * @see ScalingPolicyResponse
+ * @see ScalingPolicy
*/
@Named("Policy:get")
@GET
@Path("/policies/{scalingPolicyId}")
@ResponseParser(ParseScalingPolicyResponse.class)
@Fallback(NullOnNotFoundOr404.class)
- ScalingPolicyResponse get(@PathParam("scalingPolicyId") String scalingPolicyId);
+ ScalingPolicy get(@PathParam("scalingPolicyId") String scalingPolicyId);
/**
* This operation updates a specific scaling policy.
* @return true if successful.
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Policy:update")
@PUT
@Path("/policies/{scalingPolicyId}")
@MapBinder(BindScalingPolicyToJson.class)
@Fallback(FalseOnNotFoundOr404.class)
- boolean update(@PathParam("scalingPolicyId") String scalingPolicyId, @PayloadParam("scalingPolicy") ScalingPolicy scalingPolicy);
+ boolean update(@PathParam("scalingPolicyId") String scalingPolicyId, @PayloadParam("scalingPolicy") CreateScalingPolicy scalingPolicy);
/**
* This operation deletes a specific scaling policy.
* @return true if successful.
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Policy:delete")
@DELETE
@@ -121,7 +121,7 @@ public interface PolicyApi extends Closeable {
/**
* This operation executes a specific scaling policy.
* @return true if successful.
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Policy:execute")
@POST
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java
index 96677bc..bacb11a 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/features/WebhookApi.java
@@ -37,8 +37,8 @@ import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rackspace.autoscale.v1.binders.BindWebhookToJson;
import org.jclouds.rackspace.autoscale.v1.binders.BindWebhookUpdateToJson;
import org.jclouds.rackspace.autoscale.v1.binders.BindWebhooksToJson;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateWebhook;
import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
-import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@@ -59,10 +59,10 @@ public interface WebhookApi extends Closeable {
* @param name The webhook name. Required.
* @param metadata A map of associated metadata. Use String keys. Required.
* @return WebhookResponse The webhook created by this call.
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:create")
@POST
@@ -70,16 +70,16 @@ public interface WebhookApi extends Closeable {
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@MapBinder(BindWebhookToJson.class)
@SelectJson("webhooks")
- FluentIterable<WebhookResponse> create(@PayloadParam("name") String name, @PayloadParam("metadata") Map<String, Object> metadata);
+ FluentIterable<Webhook> create(@PayloadParam("name") String name, @PayloadParam("metadata") Map<String, Object> metadata);
/**
* Create webhooks.
* @param webhooks A list of webhooks.
* @return WebhookResponse The webhook created by this call.
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:create")
@POST
@@ -87,38 +87,38 @@ public interface WebhookApi extends Closeable {
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@MapBinder(BindWebhooksToJson.class)
@SelectJson("webhooks")
- FluentIterable<WebhookResponse> create(@PayloadParam("webhooks") List<Webhook> webhooks);
+ FluentIterable<Webhook> create(@PayloadParam("webhooks") List<CreateWebhook> webhooks);
/**
* List webhooks.
* @return A list of webhooks
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:list")
@GET
@Path("/webhooks")
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@SelectJson("webhooks")
- FluentIterable<WebhookResponse> list();
+ FluentIterable<Webhook> list();
/**
* Get a webhook.
* @param String id The id of the webhook.
* @return The webhook
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:get")
@GET
@Path("/webhooks/{webhookId}")
@Fallback(NullOnNotFoundOr404.class)
@SelectJson("webhook")
- WebhookResponse get(@PathParam("webhookId") String id);
+ Webhook get(@PathParam("webhookId") String id);
/**
* Update a webhook.
@@ -126,10 +126,10 @@ public interface WebhookApi extends Closeable {
* @param name The webhook name
* @param metadata A map of associated metadata. Use String keys.
* @return true when successful.
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:update")
@PUT
@@ -142,10 +142,10 @@ public interface WebhookApi extends Closeable {
* Delete a webhook.
* @param String id The id of the webhook.
* @return true if successful.
+ * @see CreateWebhook
* @see Webhook
- * @see WebhookResponse
* @see Group
- * @see ScalingPolicy
+ * @see CreateScalingPolicy
*/
@Named("Webhook:delete")
@DELETE
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseGroupResponse.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseGroupResponse.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseGroupResponse.java
index 27d6309..4abe892 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseGroupResponse.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseGroupResponse.java
@@ -32,9 +32,9 @@ import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration.LaunchConfigurationType;
import org.jclouds.rackspace.autoscale.v1.domain.LoadBalancer;
import org.jclouds.rackspace.autoscale.v1.domain.Personality;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
+import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -67,7 +67,7 @@ public class ParseGroupResponse implements Function<HttpResponse, Group> {
Map<String, Object> group = (Map<String, Object>) result.get("group");
Map<String, Object> groupConfigurationMap = (Map<String, Object>) group.get("groupConfiguration");
Map<String, Object> launchConfigurationMap = (Map<String, Object>) group.get("launchConfiguration");
- ImmutableList.Builder<ScalingPolicyResponse> scalingPoliciesList = ImmutableList.builder();
+ ImmutableList.Builder<ScalingPolicy> scalingPoliciesList = ImmutableList.builder();
Map<String, Object> args = (Map<String, Object>) launchConfigurationMap.get("args");
Map<String, Object> server = (Map<String, Object>) args.get("server");
@@ -125,8 +125,8 @@ public class ParseGroupResponse implements Function<HttpResponse, Group> {
Double d = (Double)scalingPolicyMap.get(targetType.toString()); // GSON only knows double now
- ScalingPolicyResponse scalingPolicyResponse =
- new ScalingPolicyResponse(
+ ScalingPolicy scalingPolicyResponse =
+ new ScalingPolicy(
(String)scalingPolicyMap.get("name"),
ScalingPolicyType.getByValue((String)scalingPolicyMap.get("type")).get(),
((Double)scalingPolicyMap.get("cooldown")).intValue(),
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPoliciesResponse.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPoliciesResponse.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPoliciesResponse.java
index c003575..4fa2fdc 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPoliciesResponse.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPoliciesResponse.java
@@ -26,9 +26,9 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.Link.Relation;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
+import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
@@ -40,7 +40,7 @@ import com.google.inject.Inject;
* This parses the scaling policy response and decouples domain objects from the json object returned by the service.
* @author Zack Shoylev
*/
-public class ParseScalingPoliciesResponse implements Function<HttpResponse, FluentIterable<ScalingPolicyResponse>> {
+public class ParseScalingPoliciesResponse implements Function<HttpResponse, FluentIterable<ScalingPolicy>> {
private final ParseJson<Map<String, List<Map<String, Object>>>> json;
@@ -53,13 +53,13 @@ public class ParseScalingPoliciesResponse implements Function<HttpResponse, Flue
* Parse a list of scaling policy responses
*/
@SuppressWarnings("unchecked")
- public FluentIterable<ScalingPolicyResponse> apply(HttpResponse from) {
+ public FluentIterable<ScalingPolicy> apply(HttpResponse from) {
// This needs to be refactored when the service is in a more final state and changing less often
// A lot of the complexity is expected to go away
Map<String, List<Map<String, Object>>> singleMap = (Map<String, List<Map<String, Object>>>) json.apply(from);
List<Map<String, Object>> result = singleMap.get("policies");
- ImmutableList.Builder<ScalingPolicyResponse> scalingPoliciesList = ImmutableList.builder();
+ ImmutableList.Builder<ScalingPolicy> scalingPoliciesList = ImmutableList.builder();
for(Map<String, Object> scalingPolicyMap : result) {
ScalingPolicyTargetType targetType = null;
@@ -77,8 +77,8 @@ public class ParseScalingPoliciesResponse implements Function<HttpResponse, Flue
}
Double d = (Double)scalingPolicyMap.get(targetType.toString()); // GSON only knows double now
- ScalingPolicyResponse scalingPolicyResponse =
- new ScalingPolicyResponse(
+ ScalingPolicy scalingPolicyResponse =
+ new ScalingPolicy(
(String)scalingPolicyMap.get("name"),
ScalingPolicyType.getByValue((String)scalingPolicyMap.get("type")).get(),
((Double)scalingPolicyMap.get("cooldown")).intValue(),
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPolicyResponse.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPolicyResponse.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPolicyResponse.java
index 392761f..6e69700 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPolicyResponse.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/functions/ParseScalingPolicyResponse.java
@@ -26,9 +26,9 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.Link.Relation;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicyResponse;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
+import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -39,7 +39,7 @@ import com.google.inject.Inject;
* This parses the scaling policy response and decouples domain objects from the json object returned by the service.
* @author Zack Shoylev
*/
-public class ParseScalingPolicyResponse implements Function<HttpResponse, ScalingPolicyResponse> {
+public class ParseScalingPolicyResponse implements Function<HttpResponse, ScalingPolicy> {
private final ParseJson<Map<String, Object>> json;
@@ -52,7 +52,7 @@ public class ParseScalingPolicyResponse implements Function<HttpResponse, Scalin
* Parse a single scaling policy response
*/
@SuppressWarnings("unchecked")
- public ScalingPolicyResponse apply(HttpResponse from) {
+ public ScalingPolicy apply(HttpResponse from) {
// This needs to be refactored when the service is in a more final state and changing less often
// A lot of the complexity is expected to go away
@@ -74,8 +74,8 @@ public class ParseScalingPolicyResponse implements Function<HttpResponse, Scalin
}
Double d = (Double)scalingPolicyMap.get(targetType.toString()); // GSON only knows double now
- ScalingPolicyResponse scalingPolicyResponse =
- new ScalingPolicyResponse(
+ ScalingPolicy scalingPolicyResponse =
+ new ScalingPolicy(
(String)scalingPolicyMap.get("name"),
ScalingPolicyType.getByValue((String)scalingPolicyMap.get("type")).get(),
((Double)scalingPolicyMap.get("cooldown")).intValue(),
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/internal/ParseHelper.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/internal/ParseHelper.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/internal/ParseHelper.java
index 8dc43f3..2f72f3e 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/internal/ParseHelper.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/internal/ParseHelper.java
@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -28,7 +28,7 @@ import com.google.common.collect.Maps;
import com.google.common.primitives.Floats;
import com.google.common.primitives.Ints;
-import static org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
+import static org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
/**
* @author Zack Shoylev
@@ -69,16 +69,16 @@ public class ParseHelper {
@SuppressWarnings("unchecked")
public static ImmutableList<Map<String, Object>> buildScalingPoliciesRequestList(Map<String, Object> postParams) {
- List<ScalingPolicy> scalingPoliciesRequest = (List<ScalingPolicy>) postParams.get("scalingPolicies");
+ List<CreateScalingPolicy> scalingPoliciesRequest = (List<CreateScalingPolicy>) postParams.get("scalingPolicies");
ImmutableList.Builder<Map<String, Object>> scalingPoliciesListBuilder = ImmutableList.builder();
- for (ScalingPolicy scalingPolicy : scalingPoliciesRequest) {
+ for (CreateScalingPolicy scalingPolicy : scalingPoliciesRequest) {
scalingPoliciesListBuilder.add(buildScalingPolicyMap(scalingPolicy));
}
return scalingPoliciesListBuilder.build();
}
- public static ImmutableMap<String, Object> buildScalingPolicyMap(ScalingPolicy scalingPolicy) {
+ public static ImmutableMap<String, Object> buildScalingPolicyMap(CreateScalingPolicy scalingPolicy) {
ImmutableMap.Builder<String, Object> scalingPolicyMapBuilder = ImmutableMap.builder();
scalingPolicyMapBuilder.put("cooldown", scalingPolicy.getCooldown());
scalingPolicyMapBuilder.put("type", scalingPolicy.getType().toString());
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java
index b8466fe..8cc15bf 100644
--- a/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java
+++ b/rackspace-autoscale/src/main/java/org/jclouds/rackspace/autoscale/v1/utils/AutoscaleUtils.java
@@ -21,7 +21,7 @@ import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
-import org.jclouds.rackspace.autoscale.v1.domain.WebhookResponse;
+import org.jclouds.rackspace.autoscale.v1.domain.Webhook;
/**
* @author Zack Shoylev
@@ -46,7 +46,7 @@ public class AutoscaleUtils {
return code == 202;
}
- public static boolean execute(WebhookResponse webhook) throws IOException {
+ public static boolean execute(Webhook webhook) throws IOException {
return execute(webhook.getAnonymousExecutionURI().get());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java
index 929e7f6..74a25a9 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiLiveTest.java
@@ -33,9 +33,9 @@ import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration.LaunchConfigurationType;
import org.jclouds.rackspace.autoscale.v1.domain.LoadBalancer;
import org.jclouds.rackspace.autoscale.v1.domain.Personality;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -88,9 +88,9 @@ public class GroupApiLiveTest extends BaseAutoscaleApiLiveTest {
.contents("VGhpcyBpcyBhIHRlc3QgZmlsZS4=").build()))
.type(LaunchConfigurationType.LAUNCH_SERVER).build();
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder().cooldown(1).type(ScalingPolicyType.WEBHOOK)
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder().cooldown(1).type(ScalingPolicyType.WEBHOOK)
.name("scale up by 1").targetType(ScalingPolicyTargetType.INCREMENTAL).target("1").build();
scalingPolicies.add(scalingPolicy);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/4f2fddbb/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiMockTest.java
----------------------------------------------------------------------
diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiMockTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiMockTest.java
index 3e1f4db..c40c271 100644
--- a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiMockTest.java
+++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/features/GroupApiMockTest.java
@@ -34,9 +34,9 @@ import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration;
import org.jclouds.rackspace.autoscale.v1.domain.LaunchConfiguration.LaunchConfigurationType;
import org.jclouds.rackspace.autoscale.v1.domain.LoadBalancer;
import org.jclouds.rackspace.autoscale.v1.domain.Personality;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyTargetType;
-import org.jclouds.rackspace.autoscale.v1.domain.ScalingPolicy.ScalingPolicyType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyTargetType;
+import org.jclouds.rackspace.autoscale.v1.domain.CreateScalingPolicy.ScalingPolicyType;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiMockTest;
import org.testng.annotations.Test;
@@ -84,9 +84,9 @@ public class GroupApiMockTest extends BaseAutoscaleApiMockTest {
.type(LaunchConfigurationType.LAUNCH_SERVER)
.build();
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(0)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by 1")
@@ -181,9 +181,9 @@ public class GroupApiMockTest extends BaseAutoscaleApiMockTest {
.type(LaunchConfigurationType.LAUNCH_SERVER)
.build();
- List<ScalingPolicy> scalingPolicies = Lists.newArrayList();
+ List<CreateScalingPolicy> scalingPolicies = Lists.newArrayList();
- ScalingPolicy scalingPolicy = ScalingPolicy.builder()
+ CreateScalingPolicy scalingPolicy = CreateScalingPolicy.builder()
.cooldown(0)
.type(ScalingPolicyType.WEBHOOK)
.name("scale up by 1")