From 5a93248e9776af67aa12d7fd31a6bfb5b7053e3c Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Mon, 31 Oct 2016 12:05:03 +0100 Subject: [PATCH] pb-updates-v3 --- profitbricks-rest/pom.xml | 2 +- .../rest/ProfitBricksApiMetadata.java | 2 +- .../binder/BaseProfitBricksRequestBinder.java | 27 +-- .../jclouds/profitbricks/rest/domain/Nic.java | 64 ++++-- .../profitbricks/rest/domain/Volume.java | 187 ++++++++++-------- .../rest/features/DataCenterApi.java | 12 +- .../rest/features/FirewallApi.java | 2 +- .../rest/features/IpBlockApi.java | 2 +- .../profitbricks/rest/features/LanApi.java | 2 +- .../profitbricks/rest/features/NicApi.java | 2 +- .../profitbricks/rest/features/ServerApi.java | 2 +- .../rest/features/SnapshotApi.java | 2 +- .../profitbricks/rest/features/VolumeApi.java | 2 +- .../rest/features/DataCenterApiMockTest.java | 2 +- .../rest/features/FirewallApiLiveTest.java | 16 +- .../rest/features/FirewallApiMockTest.java | 4 +- .../rest/features/ImageApiMockTest.java | 4 +- .../rest/features/IpBlockApiMockTest.java | 2 +- .../rest/features/LanApiMockTest.java | 4 +- .../rest/features/NicApiMockTest.java | 2 +- .../rest/features/ServerApiLiveTest.java | 113 ++++++----- .../rest/features/ServerApiMockTest.java | 4 +- .../rest/features/SnapshotApiMockTest.java | 4 +- .../rest/features/VolumeApiMockTest.java | 2 +- .../internal/BaseProfitBricksApiMockTest.java | 4 +- .../internal/BaseProfitBricksLiveTest.java | 29 ++- 26 files changed, 286 insertions(+), 212 deletions(-) diff --git a/profitbricks-rest/pom.xml b/profitbricks-rest/pom.xml index 3cb63f0f7..39fe0f4aa 100644 --- a/profitbricks-rest/pom.xml +++ b/profitbricks-rest/pom.xml @@ -32,7 +32,7 @@ bundle - https://api.profitbricks.com/rest/v2/ + https://api.profitbricks.com/cloudapi/v3/ FIXME FIXME 1.3 diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/ProfitBricksApiMetadata.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/ProfitBricksApiMetadata.java index 6bb680c4e..a39f79821 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/ProfitBricksApiMetadata.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/ProfitBricksApiMetadata.java @@ -54,7 +54,7 @@ protected Builder() { .identityName("API Username") .credentialName("API Password") .documentation(URI.create("https://devops.profitbricks.com/api/rest/")) - .defaultEndpoint("https://api.profitbricks.com/rest/v2/") + .defaultEndpoint("https://api.profitbricks.com/cloudapi/v3/") .view(ComputeServiceContext.class) .defaultProperties(ProfitBricksApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.>builder() diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/BaseProfitBricksRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/BaseProfitBricksRequestBinder.java index b5bf528b8..9c44d4baa 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/BaseProfitBricksRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/BaseProfitBricksRequestBinder.java @@ -16,18 +16,18 @@ */ package org.apache.jclouds.profitbricks.rest.binder; -import java.util.Map; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Strings; +import com.google.common.base.Supplier; import com.google.inject.Inject; +import java.net.URI; import java.util.HashMap; -import org.jclouds.json.Json; +import java.util.Map; +import org.jclouds.http.HttpRequest; import org.jclouds.io.MutableContentMetadata; import org.jclouds.io.payloads.BaseMutableContentMetadata; -import java.net.URI; -import com.google.common.base.Supplier; -import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.json.Json; +import org.jclouds.rest.MapBinder; public abstract class BaseProfitBricksRequestBinder implements MapBinder { @@ -69,7 +69,7 @@ protected static String nullableToString(Object object) { protected R createRequest(R fromRequest, String payload) { MutableContentMetadata metadata = new BaseMutableContentMetadata(); - metadata.setContentType("application/vnd.profitbricks.resource+json"); + metadata.setContentType("application/json"); metadata.setContentLength(Long.valueOf(payload.getBytes().length)); fromRequest.setPayload(payload); @@ -80,14 +80,15 @@ protected R createRequest(R fromRequest, String payload) @SuppressWarnings("unchecked") protected R genRequest(String path, R fromRequest) { R request = (R) fromRequest.toBuilder() - .replacePath(endpointSupplier.get().getPath() + path) - .build(); - + .replacePath(endpointSupplier.get().getPath() + path) + .build(); + return request; } - + protected void putIfPresent(Map list, String key, Object value) { - if (value != null) + if (value != null) { list.put(key, value); + } } } diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Nic.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Nic.java index 4071dad06..9f8b40a4d 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Nic.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Nic.java @@ -17,22 +17,22 @@ package org.apache.jclouds.profitbricks.rest.domain; import com.google.auto.value.AutoValue; -import java.util.List; -import org.jclouds.json.SerializedNames; import com.google.common.collect.ImmutableList; import static com.google.common.collect.ImmutableList.copyOf; +import java.util.List; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; @AutoValue public abstract class Nic extends Trackable { public abstract String id(); - + @Nullable public abstract String dataCenterId(); - + @Nullable - public abstract String serverId(); + public abstract String serverId(); public abstract String type(); @@ -68,15 +68,18 @@ public abstract static class Properties { public abstract int lan(); + @Nullable + public abstract Boolean nat(); + @Nullable public abstract Boolean firewallActive(); @Nullable public abstract Entities entities(); - @SerializedNames({"name", "mac", "ips", "dhcp", "lan", "firewallActive", "entities"}) - public static Properties create(String name, String mac, List ips, Boolean dhcp, int lan, Boolean firewallactive, Entities entities) { - return new AutoValue_Nic_Properties(name, mac, ips == null ? ImmutableList.of() : copyOf(ips), dhcp, lan, firewallactive, entities); + @SerializedNames({"name", "mac", "ips", "dhcp", "lan", "nat", "firewallActive", "entities"}) + public static Properties create(String name, String mac, List ips, Boolean dhcp, int lan, Boolean nat, Boolean firewallactive, Entities entities) { + return new AutoValue_Nic_Properties(name, mac, ips == null ? ImmutableList.of() : copyOf(ips), dhcp, lan, nat, firewallactive, entities); } } @@ -87,10 +90,10 @@ public abstract static class Entities { @SerializedNames({"firewallrules"}) public static Entities create(FirewallRules firewallrules) { - return new AutoValue_Nic_Entities(firewallrules); + return new AutoValue_Nic_Entities(firewallrules); } } - + public static final class Request { public static CreatePayload.Builder creatingBuilder() { @@ -114,28 +117,41 @@ public abstract static class CreatePayload { public abstract Boolean dhcp(); public abstract int lan(); - + + @Nullable + public abstract Boolean nat(); + @Nullable public abstract Boolean firewallActive(); - + @Nullable public abstract List firewallrules(); public abstract String dataCenterId(); + public abstract String serverId(); @AutoValue.Builder public abstract static class Builder { public abstract Builder name(String name); + public abstract Builder ips(List ips); + public abstract Builder dhcp(Boolean dhcp); + public abstract Builder lan(int lan); + + public abstract Builder nat(Boolean nat); + public abstract Builder firewallActive(Boolean firewallActive); + public abstract Builder firewallrules(List firewallrules); + public abstract Builder dataCenterId(String dataCenterId); + public abstract Builder serverId(String serverId); - + abstract CreatePayload autoBuild(); public CreatePayload build() { @@ -158,21 +174,35 @@ public abstract static class UpdatePayload { @Nullable public abstract Integer lan(); - + + @Nullable + public abstract Boolean nat(); + public abstract String dataCenterId(); + public abstract String serverId(); + public abstract String id(); @AutoValue.Builder public abstract static class Builder { + public abstract Builder name(String name); + public abstract Builder ips(List ips); + public abstract Builder dhcp(Boolean dhcp); + public abstract Builder lan(Integer lan); + + public abstract Builder nat(Boolean nat); + public abstract Builder dataCenterId(String dataCenterId); + public abstract Builder serverId(String serverId); + public abstract Builder id(String id); - + abstract UpdatePayload autoBuild(); public UpdatePayload build() { @@ -180,9 +210,7 @@ public UpdatePayload build() { } } } - + } - } - diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Volume.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Volume.java index e0109f0a8..4e23ab748 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Volume.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Volume.java @@ -18,101 +18,103 @@ import com.google.auto.value.AutoValue; import com.google.common.base.Enums; +import static com.google.common.base.Preconditions.checkArgument; +import java.util.Set; import org.apache.jclouds.profitbricks.rest.util.Passwords; import org.jclouds.javax.annotation.Nullable; import org.jclouds.json.SerializedNames; -import static com.google.common.base.Preconditions.checkArgument; -import java.util.Set; @AutoValue public abstract class Volume extends Trackable { - public abstract String id(); - - @Nullable - public abstract String dataCenterId(); + public abstract String id(); - public abstract String type(); + @Nullable + public abstract String dataCenterId(); - public abstract String href(); + public abstract String type(); - @Nullable - public abstract Metadata metadata(); + public abstract String href(); - @Nullable - public abstract Properties properties(); + @Nullable + public abstract Metadata metadata(); - @SerializedNames({"id", "dataCenterId", "type", "href", "metadata", "properties"}) - public static Volume create(String id, String dataCenterId, String type, String href, Metadata metadata, Properties properties) { - return new AutoValue_Volume(id, dataCenterId, type, href, metadata, properties); - } + @Nullable + public abstract Properties properties(); - @AutoValue - public abstract static class Properties { + @SerializedNames({"id", "dataCenterId", "type", "href", "metadata", "properties"}) + public static Volume create(String id, String dataCenterId, String type, String href, Metadata metadata, Properties properties) { + return new AutoValue_Volume(id, dataCenterId, type, href, metadata, properties); + } - public enum BusType { + @AutoValue + public abstract static class Properties { - IDE, SCSI, VIRTIO, UNRECOGNIZED; + public enum BusType { - public static BusType fromValue(String value) { - return Enums.getIfPresent(BusType.class, value).or(UNRECOGNIZED); - } - } + IDE, SCSI, VIRTIO, UNRECOGNIZED; + + public static BusType fromValue(String value) { + return Enums.getIfPresent(BusType.class, value).or(UNRECOGNIZED); + } + } - @Nullable - public abstract String name(); + @Nullable + public abstract String name(); - @Nullable - public abstract VolumeType type(); + @Nullable + public abstract VolumeType type(); - public abstract float size(); + public abstract float size(); - @Nullable - public abstract String image(); + @Nullable + public abstract AvailabilityZone availabilityZone(); - @Nullable - public abstract String imagePassword(); - - @Nullable - public abstract BusType bus(); + @Nullable + public abstract String image(); - @Nullable - public abstract LicenceType licenceType(); + @Nullable + public abstract String imagePassword(); - public abstract boolean cpuHotPlug(); + @Nullable + public abstract BusType bus(); - public abstract boolean cpuHotUnplug(); + @Nullable + public abstract LicenceType licenceType(); - public abstract boolean ramHotPlug(); + public abstract boolean cpuHotPlug(); - public abstract boolean ramHotUnplug(); + public abstract boolean cpuHotUnplug(); - public abstract boolean nicHotPlug(); + public abstract boolean ramHotPlug(); - public abstract boolean nicHotUnplug(); + public abstract boolean ramHotUnplug(); - public abstract boolean discVirtioHotPlug(); + public abstract boolean nicHotPlug(); - public abstract boolean discVirtioHotUnplug(); + public abstract boolean nicHotUnplug(); - public abstract boolean discScsiHotPlug(); + public abstract boolean discVirtioHotPlug(); - public abstract boolean discScsiHotUnplug(); + public abstract boolean discVirtioHotUnplug(); - @Nullable - public abstract Integer deviceNumber(); + public abstract boolean discScsiHotPlug(); - @SerializedNames({"name", "type", "size", "image", "imagePassword", "bus", "licenceType", "cpuHotPlug", "cpuHotUnplug", "ramHotPlug", "ramHotUnplug", "nicHotPlug", "nicHotUnplug", "discVirtioHotPlug", "discVirtioHotUnplug", "discScsiHotPlug", "discScsiHotUnplug", "deviceNumber"}) - public static Volume.Properties create(String name, VolumeType type, float size, String image, String imagePassword, BusType bus, LicenceType licenceType, - boolean cpuHotPlug, boolean cpuHotUnplug, boolean ramHotPlug, boolean ramHotUnplug, boolean nicHotPlug, boolean nicHotUnplug, boolean discVirtioHotPlug, - boolean discVirtioHotUnplug, boolean discScsiHotPlug, boolean discScsiHotUnplug, int deviceNumber) { + public abstract boolean discScsiHotUnplug(); - return new AutoValue_Volume_Properties(name, type, size, image, imagePassword, bus, licenceType, cpuHotPlug, cpuHotUnplug, ramHotPlug, ramHotUnplug, nicHotPlug, nicHotUnplug, discVirtioHotPlug, discVirtioHotUnplug, discScsiHotPlug, discScsiHotUnplug, deviceNumber); + @Nullable + public abstract Integer deviceNumber(); - } - } + @SerializedNames({"name", "type", "size", "availabilityZone", "image", "imagePassword", "bus", "licenceType", "cpuHotPlug", "cpuHotUnplug", "ramHotPlug", "ramHotUnplug", "nicHotPlug", "nicHotUnplug", "discVirtioHotPlug", "discVirtioHotUnplug", "discScsiHotPlug", "discScsiHotUnplug", "deviceNumber"}) + public static Volume.Properties create(String name, VolumeType type, float size, AvailabilityZone availabilityZone, String image, String imagePassword, BusType bus, LicenceType licenceType, + boolean cpuHotPlug, boolean cpuHotUnplug, boolean ramHotPlug, boolean ramHotUnplug, boolean nicHotPlug, boolean nicHotUnplug, boolean discVirtioHotPlug, + boolean discVirtioHotUnplug, boolean discScsiHotPlug, boolean discScsiHotUnplug, int deviceNumber) { + + return new AutoValue_Volume_Properties(name, type, size, availabilityZone, image, imagePassword, bus, licenceType, cpuHotPlug, cpuHotUnplug, ramHotPlug, ramHotUnplug, nicHotPlug, nicHotUnplug, discVirtioHotPlug, discVirtioHotUnplug, discScsiHotPlug, discScsiHotUnplug, deviceNumber); + + } + } - public static final class Request { public static CreatePayload.Builder creatingBuilder() { @@ -122,15 +124,15 @@ public static CreatePayload.Builder creatingBuilder() { public static UpdatePayload.Builder updatingBuilder() { return new AutoValue_Volume_Request_UpdatePayload.Builder(); } - + public static CreateSnapshotPayload.Builder createSnapshotBuilder() { return new AutoValue_Volume_Request_CreateSnapshotPayload.Builder(); } - + public static RestoreSnapshotPayload.Builder restoreSnapshotBuilder() { return new AutoValue_Volume_Request_RestoreSnapshotPayload.Builder(); } - + @AutoValue public abstract static class CreatePayload { @@ -138,15 +140,18 @@ public abstract static class CreatePayload { public abstract String name(); public abstract VolumeType type(); - + public abstract int size(); @Nullable public abstract Set sshKeys(); - + @Nullable public abstract String image(); + @Nullable + public abstract AvailabilityZone availabilityZone(); + @Nullable public abstract String imagePassword(); @@ -155,35 +160,46 @@ public abstract static class CreatePayload { @Nullable public abstract LicenceType licenceType(); - + public abstract String dataCenterId(); @AutoValue.Builder public abstract static class Builder { public abstract Builder name(String name); + public abstract Builder type(VolumeType type); + public abstract Builder sshKeys(Set list); + public abstract Builder size(int size); + + public abstract Builder availabilityZone(AvailabilityZone size); + public abstract Builder image(String image); + public abstract Builder imagePassword(String imagePassword); + public abstract Builder bus(Properties.BusType bus); + public abstract Builder licenceType(LicenceType licenceType); + public abstract Builder dataCenterId(String dataCenterId); abstract CreatePayload autoBuild(); public CreatePayload build() { CreatePayload payload = autoBuild(); - - if (payload.imagePassword() != null) + + if (payload.imagePassword() != null) { checkArgument(Passwords.isValidPassword(payload.imagePassword()), "Password's format is not valid"); - + } + checkArgument( - payload.image() != null || payload.licenceType() != null, - "Either image or licenceType need to be present" + payload.image() != null || payload.licenceType() != null, + "Either image or licenceType need to be present" ); - + return payload; } } @@ -201,17 +217,27 @@ public abstract static class UpdatePayload { @Nullable public abstract Properties.BusType bus(); - + + @Nullable + public abstract AvailabilityZone availabilityZone(); + public abstract String dataCenterId(); + public abstract String id(); @AutoValue.Builder public abstract static class Builder { public abstract Builder name(String name); + public abstract Builder size(Integer size); + public abstract Builder bus(Properties.BusType bus); + + public abstract Builder availabilityZone(AvailabilityZone size); + public abstract Builder dataCenterId(String dataCenterId); + public abstract Builder id(String id); abstract UpdatePayload autoBuild(); @@ -221,7 +247,7 @@ public UpdatePayload build() { } } } - + @AutoValue public abstract static class CreateSnapshotPayload { @@ -230,16 +256,20 @@ public abstract static class CreateSnapshotPayload { @Nullable public abstract String description(); - + public abstract String dataCenterId(); + public abstract String volumeId(); @AutoValue.Builder public abstract static class Builder { public abstract Builder name(String name); + public abstract Builder description(String description); + public abstract Builder dataCenterId(String dataCenterId); + public abstract Builder volumeId(String volumeId); abstract CreateSnapshotPayload autoBuild(); @@ -250,19 +280,23 @@ public CreateSnapshotPayload build() { } } - + @AutoValue public abstract static class RestoreSnapshotPayload { public abstract String snapshotId(); + public abstract String dataCenterId(); + public abstract String volumeId(); @AutoValue.Builder public abstract static class Builder { public abstract Builder snapshotId(String snapshotId); + public abstract Builder dataCenterId(String dataCenterId); + public abstract Builder volumeId(String volumeId); abstract RestoreSnapshotPayload autoBuild(); @@ -273,8 +307,7 @@ public RestoreSnapshotPayload build() { } } - + } - - + } diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApi.java index 34ce39f12..fa1e67cfb 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApi.java @@ -17,13 +17,13 @@ package org.apache.jclouds.profitbricks.rest.features; import static com.google.common.base.Preconditions.checkNotNull; - +import com.google.inject.Inject; +import com.google.inject.TypeLiteral; import java.io.Closeable; import java.net.URI; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.inject.Named; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -31,7 +31,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; - import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; import org.apache.jclouds.profitbricks.rest.functions.ParseRequestStatusURI; @@ -51,9 +50,6 @@ import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.binders.BindToJsonPayload; -import com.google.inject.Inject; -import com.google.inject.TypeLiteral; - @Path("/datacenters") @RequestFilters(BasicAuthentication.class) public interface DataCenterApi extends Closeable { @@ -92,7 +88,7 @@ public interface DataCenterApi extends Closeable { @Named("datacenter:create") @POST @ResponseParser(DataCenterParser.class) - @Produces("application/vnd.profitbricks.resource+json") + @Produces("application/json") @MapBinder(DataCenterCreateMapBinder.class) DataCenter create( @PayloadParam("name") String name, @@ -104,7 +100,7 @@ DataCenter create( @PATCH @Path("/{id}") @ResponseParser(DataCenterParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") @MapBinder(BindToJsonPayload.class) DataCenter update( @PathParam("id") String id, diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/FirewallApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/FirewallApi.java index 82344cd0d..357fed09d 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/FirewallApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/FirewallApi.java @@ -94,7 +94,7 @@ public interface FirewallApi extends Closeable { @PATCH @MapBinder(UpdateFirewallRuleRequestBinder.class) @ResponseParser(FirewallApi.FirewallRuleParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") FirewallRule update(@PayloadParam("firewallRule") FirewallRule.Request.UpdatePayload payload); @Named("firewallRule:delete") diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApi.java index 5b0d3517b..c29c97501 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApi.java @@ -71,7 +71,7 @@ public interface IpBlockApi extends Closeable { @Named("IpBlock:create") @POST - @Produces("application/vnd.profitbricks.resource+json") + @Produces("application/json") @ResponseParser(IpBlockApi.IpBlockParser.class) IpBlock create(@BinderParam(BindToJsonPayload.class) IpBlock.Request.CreatePayload payload); diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/LanApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/LanApi.java index 8900475f7..add95a9fb 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/LanApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/LanApi.java @@ -95,7 +95,7 @@ public interface LanApi extends Closeable { @Path("/{lanId}") @MapBinder(UpdateLanRequestBinder.class) @ResponseParser(LanApi.LanParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") Lan update(@PayloadParam("lan") Lan.Request.UpdatePayload payload); @Named("lan:delete") diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/NicApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/NicApi.java index 0fc46d8f2..e3cd7aa6d 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/NicApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/NicApi.java @@ -95,7 +95,7 @@ public interface NicApi extends Closeable { @Path("/{nicId}") @MapBinder(UpdateNicRequestBinder.class) @ResponseParser(NicApi.NicParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") Nic update(@PayloadParam("nic") Nic.Request.UpdatePayload payload); @Named("nic:delete") diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/ServerApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/ServerApi.java index 3987e59c4..8a9ff157e 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/ServerApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/ServerApi.java @@ -99,7 +99,7 @@ public interface ServerApi extends Closeable { @Path("/{serverId}") @MapBinder(UpdateServerRequestBinder.class) @ResponseParser(ServerApi.ServerParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") Server updateServer(@PayloadParam("server") Server.Request.UpdatePayload payload); @Named("server:delete") diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApi.java index fd134f577..515100633 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApi.java @@ -82,7 +82,7 @@ public interface SnapshotApi extends Closeable { @Path("/{snapshotId}") @MapBinder(UpdateSnapshotRequestBinder.class) @ResponseParser(SnapshotApi.SnapshotParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") Snapshot update(@PayloadParam("snapshot") Snapshot.Request.UpdatePayload payload); @Named("snapshot:delete") diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java index edb1d6aed..c27455a30 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java @@ -98,7 +98,7 @@ public interface VolumeApi extends Closeable { @Path("/{volumeId}") @MapBinder(UpdateVolumeRequestBinder.class) @ResponseParser(VolumeApi.VolumeParser.class) - @Produces("application/vnd.profitbricks.partial-properties+json") + @Produces("application/json") Volume updateVolume(@PayloadParam("volume") Volume.Request.UpdatePayload payload); @Named("volume:delete") diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java index d5cf59446..5a5777eaf 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java @@ -62,7 +62,7 @@ public void testGetListWith404() throws InterruptedException { public void testGetDataCenter() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/datacenter/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java index 10631454e..d477a30a8 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java @@ -18,23 +18,22 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; - import java.net.URI; import java.util.List; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; -import org.apache.jclouds.profitbricks.rest.domain.State; import org.apache.jclouds.profitbricks.rest.domain.FirewallRule; import org.apache.jclouds.profitbricks.rest.domain.Nic; import org.apache.jclouds.profitbricks.rest.domain.Server; +import org.apache.jclouds.profitbricks.rest.domain.State; import org.apache.jclouds.profitbricks.rest.ids.ServerRef; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; @Test(groups = "live", testName = "FirewallApiLiveTest") public class FirewallApiLiveTest extends BaseProfitBricksLiveTest { @@ -122,7 +121,7 @@ public void testListRules() { } @Test(dependsOnMethods = "testCreateFirewallRule") - public void testUpdateFirewallRule() { + public void testUpdateFirewallRule() throws InterruptedException { assertDataCenterAvailable(dataCenter); FirewallRule updated = firewallApi().update(FirewallRule.Request.updatingBuilder() @@ -134,7 +133,10 @@ public void testUpdateFirewallRule() { .build()); assertFirewallRuleAvailable(updated); - + assertRequestCompleted(testFirewallRule); + //thread sleep added becuase the API would not give back the updated name value unless you wait + // + Thread.sleep(3000); FirewallRule firewallRule = firewallApi().get(dataCenter.id(), testServer.id(), testNic.id(), testFirewallRule.id()); assertEquals(firewallRule.properties().name(), "apache-firewall"); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiMockTest.java index 4f8067934..ea6360440 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiMockTest.java @@ -83,7 +83,7 @@ public void testGetRuleListWith404AndDepth() throws InterruptedException { public void testGetFirewallRule() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/firewall/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); @@ -99,7 +99,7 @@ public void testGetFirewallRule() throws InterruptedException { public void testGetFirewallRuleWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/firewall/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiMockTest.java index a668dc7b7..103442555 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiMockTest.java @@ -74,7 +74,7 @@ public void testGetListWith404() throws InterruptedException { public void testGetImage() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/image/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); @@ -91,7 +91,7 @@ public void testGetImage() throws InterruptedException { public void testGetImageWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/image/get-depth-5.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java index db68b3df9..9970bd53b 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java @@ -87,7 +87,7 @@ public void testListWith404WithDepth() throws InterruptedException { public void testGetIpBlock() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/ipblock/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiMockTest.java index 9c11d4f18..9c6969734 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiMockTest.java @@ -84,7 +84,7 @@ public void testListWith404WithDepth() throws InterruptedException { public void testGetLan() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/lan/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); @@ -112,7 +112,7 @@ public void testGetLanWith404() throws InterruptedException { public void testGetLanWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/lan/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiMockTest.java index 1827f678a..80ae74c28 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiMockTest.java @@ -58,7 +58,7 @@ public void testGetListWith404() throws InterruptedException { public void testGetNic() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/nic/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java index 252754726..e4b30752e 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java @@ -17,15 +17,17 @@ package org.apache.jclouds.profitbricks.rest.features; import com.google.common.base.Predicate; - import java.net.URI; import java.util.List; import org.apache.jclouds.profitbricks.rest.domain.CpuFamily; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.Image; +import org.apache.jclouds.profitbricks.rest.domain.LicenceType; +import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.apache.jclouds.profitbricks.rest.domain.State; import org.apache.jclouds.profitbricks.rest.domain.Volume; +import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; import org.apache.jclouds.profitbricks.rest.ids.ServerRef; import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; @@ -39,28 +41,28 @@ @Test(groups = "live", testName = "ServerApiLiveTest") public class ServerApiLiveTest extends BaseProfitBricksLiveTest { - + private DataCenter dataCenter; private Server testServer; private Image attachedCdrom; private Volume attachedVolume; - + @BeforeClass public void setupTest() { dataCenter = createDataCenter(); } - + @AfterClass(alwaysRun = true) public void teardownTest() { if (dataCenter != null) { deleteDataCenter(dataCenter.id()); } } - + @Test public void testCreateServer() { assertNotNull(dataCenter); - + testServer = serverApi().createServer( Server.Request.creatingBuilder() .dataCenterId(dataCenter.id()) @@ -69,30 +71,30 @@ public void testCreateServer() { .cores(1) .ram(1024) .build()); - + assertRequestCompleted(testServer); assertNotNull(testServer); assertEquals(testServer.properties().name(), "jclouds-node"); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); } - + @Test(dependsOnMethods = "testCreateServer") public void testGetServer() { Server server = serverApi().getServer(dataCenter.id(), testServer.id()); - + assertNotNull(server); assertEquals(server.id(), testServer.id()); } - + @Test(dependsOnMethods = "testCreateServer") public void testList() { List servers = serverApi().getList(dataCenter.id()); - + assertNotNull(servers); assertFalse(servers.isEmpty()); assertEquals(servers.size(), 1); } - + @Test(dependsOnMethods = "testGetServer") public void testUpdateServer() { assertDataCenterAvailable(dataCenter); @@ -105,58 +107,58 @@ public void testUpdateServer() { .ram(1024 * 2) .cores(2) .build()); - + assertRequestCompleted(updated); assertNodeAvailable(ServerRef.create(dataCenter.id(), testServer.id())); assertDataCenterAvailable(dataCenter); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(dataCenter.id(), testServer.id()); - + assertEquals(server.properties().name(), "apache-node"); } - + @Test(dependsOnMethods = "testUpdateServer") public void testStopServer() { URI uri = serverApi().stopServer(testServer.dataCenterId(), testServer.id()); assertRequestCompleted(uri); assertNodeSuspended(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.SHUTOFF); } - + @Test(dependsOnMethods = "testStopServer") public void testStartServer() { URI uri = serverApi().startServer(testServer.dataCenterId(), testServer.id()); assertRequestCompleted(uri); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.RUNNING); } - + @Test(dependsOnMethods = "testStartServer") public void testRebootServer() { URI uri = serverApi().rebootServer(testServer.dataCenterId(), testServer.id()); assertRequestCompleted(uri); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.RUNNING); } - + @Test(dependsOnMethods = "testRebootServer") public void testListVolumes() { List volumes = serverApi().listAttachedVolumes(testServer.dataCenterId(), testServer.id()); assertTrue(volumes.isEmpty()); } - + @Test(dependsOnMethods = "testListVolumes") public void testAttachVolume() { Volume volume = createVolume(dataCenter); assertVolumeAvailable(VolumeRef.create(dataCenter.id(), volume.id())); - + attachedVolume = serverApi().attachVolume( Server.Request.attachVolumeBuilder() .dataCenterId(testServer.dataCenterId()) @@ -164,90 +166,105 @@ public void testAttachVolume() { .volumeId(volume.id()) .build() ); - + assertRequestCompleted(attachedVolume); assertVolumeAttached(testServer, volume.id()); - + List volumes = serverApi().listAttachedVolumes(testServer.dataCenterId(), testServer.id()); assertEquals(volumes.size(), 1); } - + @Test(dependsOnMethods = "testAttachVolume") public void testGetVolume() { Volume volume = serverApi().getVolume(testServer.dataCenterId(), testServer.id(), attachedVolume.id()); assertEquals(volume.id(), attachedVolume.id()); } - + @Test(dependsOnMethods = "testGetVolume") public void testDetachVolume() { URI uri = serverApi().detachVolume(testServer.dataCenterId(), testServer.id(), attachedVolume.id()); assertRequestCompleted(uri); assertVolumeDetached(testServer, attachedVolume.id()); } - + @Test(dependsOnMethods = "testDetachVolume") public void testListCdroms() { List images = serverApi().listAttachedCdroms(testServer.dataCenterId(), testServer.id()); assertTrue(images.isEmpty()); } - + @Test(dependsOnMethods = "testListCdroms") public void testAttachCdrom() { + + List images = api.imageApi().getList(new DepthOptions().depth(5)); + + Image testImage = null; + + for (Image image : images) { + if (image.metadata().state() == State.AVAILABLE + && image.properties().isPublic() + && image.properties().imageType() == Image.Type.CDROM + && image.properties().location() == US_LAS + && image.properties().licenceType() == LicenceType.LINUX + && (testImage == null || testImage.properties().size() > image.properties().size())) { + testImage = image; + } + } attachedCdrom = serverApi().attachCdrom( Server.Request.attachCdromBuilder() .dataCenterId(testServer.dataCenterId()) .serverId(testServer.id()) - .imageId("7cb4b3a3-50c3-11e5-b789-52540066fee9") + .imageId(testImage.id()) .build() ); assertRequestCompleted(attachedCdrom); - assertEquals(attachedCdrom.properties().name(), "ubuntu-14.04.3-server-amd64.iso"); + assertEquals(attachedCdrom.properties().name(), testImage.properties().name()); assertCdromAvailable(testServer, attachedCdrom.id()); - - List images = serverApi().listAttachedCdroms(testServer.dataCenterId(), testServer.id()); - assertEquals(images.size(), 1); + + List attachedimages = serverApi().listAttachedCdroms(testServer.dataCenterId(), testServer.id()); + assertEquals(attachedimages.size(), 1); } - + @Test(dependsOnMethods = "testAttachCdrom") public void testRetrieveAttachedCdrom() { Image cdrom = serverApi().getCdrom(testServer.dataCenterId(), testServer.id(), attachedCdrom.id()); assertEquals(cdrom.id(), attachedCdrom.id()); } - + @Test(dependsOnMethods = "testRetrieveAttachedCdrom") public void testDetachCdrom() { URI uri = serverApi().detachCdrom(testServer.dataCenterId(), testServer.id(), attachedCdrom.id()); assertRequestCompleted(uri); assertCdromRemoved(testServer, attachedCdrom.id()); } - + @Test(dependsOnMethods = "testDetachCdrom") public void testDeleteServer() { URI uri = serverApi().deleteServer(testServer.dataCenterId(), testServer.id()); assertRequestCompleted(uri); assertNodeRemoved(ServerRef.create(dataCenter.id(), testServer.id())); } - + private ServerApi serverApi() { return api.serverApi(); } - + private void assertCdromAvailable(Server server, String cdRomId) { assertPredicate(new Predicate() { @Override public boolean apply(String args) { String[] params = args.split(","); Image cdrom = serverApi().getCdrom(params[0], params[1], params[2]); - + if (cdrom == null || cdrom.metadata() == null) { return false; } - + return cdrom.metadata().state() == State.AVAILABLE; } }, complexId(server.dataCenterId(), server.id(), cdRomId)); } - + private void assertCdromRemoved(Server server, String cdRomId) { assertPredicate(new Predicate() { @Override @@ -257,23 +274,23 @@ public boolean apply(String args) { } }, complexId(server.dataCenterId(), server.id(), cdRomId)); } - + private void assertVolumeAttached(Server server, String volumeId) { assertPredicate(new Predicate() { @Override public boolean apply(String args) { String[] params = args.split(","); Volume volume = serverApi().getVolume(params[0], params[1], params[2]); - + if (volume == null || volume.metadata() == null) { return false; } - + return volume.metadata().state() == State.AVAILABLE; } }, complexId(server.dataCenterId(), server.id(), volumeId)); } - + private void assertVolumeDetached(Server server, String volumeId) { assertPredicate(new Predicate() { @Override @@ -283,5 +300,5 @@ public boolean apply(String args) { } }, complexId(server.dataCenterId(), server.id(), volumeId)); } - + } diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiMockTest.java index 1b116177b..d9043403f 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiMockTest.java @@ -76,7 +76,7 @@ public void testGetListWith404() throws InterruptedException { public void testGetServer() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/server/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); @@ -93,7 +93,7 @@ public void testGetServer() throws InterruptedException { public void testGetServerWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/server/get-depth-5.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java index 034b438f8..c6cd99b0a 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java @@ -83,7 +83,7 @@ public void testGetListWithDepth404() throws InterruptedException { public void testGetSnapshot() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/snapshot/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); @@ -100,7 +100,7 @@ public void testGetSnapshot() throws InterruptedException { public void testGetSnapshotWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/snapshot/get-depth-5.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiMockTest.java index 52d40dec3..36c22cf63 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiMockTest.java @@ -61,7 +61,7 @@ public void testGetListWith404() throws InterruptedException { public void testGetVolume() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/volume/get.json")); - response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + response.setHeader("Content-Type", "application/json"); server.enqueue(response); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java index bc36ef4c0..125882897 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java @@ -113,10 +113,10 @@ protected RecordedRequest assertSent(MockWebServer server, String method, String throws InterruptedException { RecordedRequest request = assertSent(server, method, path); - String expectedContentType = "application/vnd.profitbricks.resource+json"; + String expectedContentType = "application/json"; if (request.getMethod().equals("PATCH")) - expectedContentType = "application/vnd.profitbricks.partial-properties+json"; + expectedContentType = "application/json"; assertEquals(request.getHeader("Content-Type"), expectedContentType); assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(json)); diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java index 2766d481b..3cacf09c6 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java @@ -16,22 +16,25 @@ */ package org.apache.jclouds.profitbricks.rest.internal; -import static org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER; -import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.testng.Assert.assertTrue; - +import com.google.common.base.Joiner; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Module; +import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; import java.net.URI; import java.util.Properties; import java.util.concurrent.TimeUnit; - import org.apache.jclouds.profitbricks.rest.ProfitBricksApi; import org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule.ComputeConstants; +import static org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER; import org.apache.jclouds.profitbricks.rest.config.ProfitBricksRateLimitModule; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.LicenceType; import org.apache.jclouds.profitbricks.rest.domain.Location; +import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS; import org.apache.jclouds.profitbricks.rest.domain.Nic; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.apache.jclouds.profitbricks.rest.domain.State; @@ -42,16 +45,10 @@ import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.apache.jclouds.profitbricks.rest.util.Trackables; import org.jclouds.apis.BaseApiLiveTest; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; import org.jclouds.util.Predicates2; - -import com.google.common.base.Joiner; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; +import static org.testng.Assert.assertTrue; public class BaseProfitBricksLiveTest extends BaseApiLiveTest {