Repository: jclouds-labs Updated Branches: refs/heads/master 11759531c -> ca57d90d8
Profitbricks REST - Snapshot API Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/ca57d90d Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/ca57d90d Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/ca57d90d Branch: refs/heads/master Commit: ca57d90d8031f873166b0087158b1f8a5decb2df Parents: 1175953 Author: mirza-spc <[email protected]> Authored: Fri Mar 4 09:35:49 2016 +0100 Committer: Ignasi Barrera <[email protected]> Committed: Wed Mar 9 23:08:39 2016 +0100 ---------------------------------------------------------------------- .../binder/BaseProfitBricksRequestBinder.java | 10 +- .../binder/image/UpdateImageRequestBinder.java | 9 +- .../binder/server/AttachCdromRequestBinder.java | 9 +- .../server/AttachVolumeRequestBinder.java | 9 +- .../server/CreateServerRequestBinder.java | 6 +- .../server/UpdateServerRequestBinder.java | 8 +- .../snapshot/UpdateSnapshotRequestBinder.java | 90 ++++++ .../volume/CreateSnapshotRequestBinder.java | 14 +- .../volume/CreateVolumeRequestBinder.java | 7 +- .../volume/RestoreSnapshotRequestBinder.java | 14 +- .../volume/UpdateVolumeRequestBinder.java | 9 +- .../profitbricks/rest/domain/Snapshot.java | 163 ++++++++--- .../profitbricks/rest/features/SnapshotApi.java | 47 +++- .../UpdateSnapshotRequestBinderTest.java | 65 +++++ .../rest/features/ImageApiLiveTest.java | 14 +- .../rest/features/ServerApiLiveTest.java | 16 +- .../rest/features/SnapshotApiLiveTest.java | 173 ++++++++++++ .../rest/features/SnapshotApiMockTest.java | 179 ++++++++++++ .../rest/features/VolumeApiLiveTest.java | 15 +- .../rest/internal/BaseProfitBricksLiveTest.java | 2 +- .../test/resources/snapshot/get-depth-5.json | 30 ++ .../src/test/resources/snapshot/get.json | 30 ++ .../test/resources/snapshot/list-depth-5.json | 97 +++++++ .../src/test/resources/snapshot/list.json | 277 +++++++++++++++++++ 24 files changed, 1162 insertions(+), 131 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/BaseProfitBricksRequestBinder.java ---------------------------------------------------------------------- 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 2fbadce..1d15bd9 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 @@ -24,16 +24,24 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; import com.google.common.base.Strings; +import com.google.inject.Inject; +import java.util.HashMap; import org.jclouds.io.MutableContentMetadata; import org.jclouds.io.payloads.BaseMutableContentMetadata; +import org.jclouds.json.Json; public abstract class BaseProfitBricksRequestBinder<T> implements MapBinder { protected final String paramName; + protected final Map<String, Object> requestBuilder; + protected final Json jsonBinder; - protected BaseProfitBricksRequestBinder(String paramName) { + @Inject + protected BaseProfitBricksRequestBinder(String paramName, Json jsonBinder) { this.paramName = checkNotNull(paramName, "Initialize 'paramName' in constructor"); + this.jsonBinder = jsonBinder; + this.requestBuilder = new HashMap<String, Object>(); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/image/UpdateImageRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/image/UpdateImageRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/image/UpdateImageRequestBinder.java index 6dd2c30..9a5e73e 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/image/UpdateImageRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/image/UpdateImageRequestBinder.java @@ -18,8 +18,6 @@ package org.apache.jclouds.profitbricks.rest.binder.image; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; -import java.util.HashMap; -import java.util.Map; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Image; import org.jclouds.http.HttpRequest; @@ -27,16 +25,11 @@ import org.jclouds.json.Json; public class UpdateImageRequestBinder extends BaseProfitBricksRequestBinder<Image.Request.UpdatePayload> { - final Map<String, Object> requestBuilder; - final Json jsonBinder; - private String imageId; @Inject UpdateImageRequestBinder(Json jsonBinder) { - super("image"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("image", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinder.java index efc1195..9cf2132 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinder.java @@ -17,8 +17,6 @@ package org.apache.jclouds.profitbricks.rest.binder.server; import com.google.inject.Inject; -import java.util.HashMap; -import java.util.Map; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.jclouds.http.HttpRequest; @@ -27,17 +25,12 @@ import static com.google.common.base.Preconditions.checkNotNull; public class AttachCdromRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.AttachCdromPayload> { - final Map<String, Object> requestBuilder; - final Json jsonBinder; - String dataCenterId; String serverId; @Inject AttachCdromRequestBinder(Json jsonBinder) { - super("cdrom"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("cdrom", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinder.java index 0ffebaa..37516f4 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinder.java @@ -17,8 +17,6 @@ package org.apache.jclouds.profitbricks.rest.binder.server; import com.google.inject.Inject; -import java.util.HashMap; -import java.util.Map; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.jclouds.http.HttpRequest; @@ -27,17 +25,12 @@ import static com.google.common.base.Preconditions.checkNotNull; public class AttachVolumeRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.AttachVolumePayload> { - final Map<String, Object> requestBuilder; - final Json jsonBinder; - String dataCenterId; String serverId; @Inject AttachVolumeRequestBinder(Json jsonBinder) { - super("volume"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("volume", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/CreateServerRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/CreateServerRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/CreateServerRequestBinder.java index bac058d..9ff4448 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/CreateServerRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/CreateServerRequestBinder.java @@ -27,15 +27,11 @@ import org.jclouds.json.Json; public class CreateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.CreatePayload> { - final Map<String, Object> requestBuilder; - final Json jsonBinder; String dataCenterId; @Inject CreateServerRequestBinder(Json jsonBinder) { - super("server"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("server", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/UpdateServerRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/UpdateServerRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/UpdateServerRequestBinder.java index 3c00111..ca1f2f0 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/UpdateServerRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/server/UpdateServerRequestBinder.java @@ -18,8 +18,6 @@ package org.apache.jclouds.profitbricks.rest.binder.server; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; -import java.util.HashMap; -import java.util.Map; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.jclouds.http.HttpRequest; @@ -27,16 +25,12 @@ import org.jclouds.json.Json; public class UpdateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.UpdatePayload> { - final Map<String, Object> requestBuilder; - final Json jsonBinder; String dataCenterId; String serverId; @Inject UpdateServerRequestBinder(Json jsonBinder) { - super("server"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("server", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinder.java new file mode 100644 index 0000000..089a237 --- /dev/null +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinder.java @@ -0,0 +1,90 @@ +/* + * 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.apache.jclouds.profitbricks.rest.binder.snapshot; + +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; +import org.apache.jclouds.profitbricks.rest.domain.Snapshot; +import org.jclouds.http.HttpRequest; +import org.jclouds.json.Json; + +public class UpdateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<Snapshot.Request.UpdatePayload> { + + private String snapshotId; + + @Inject + UpdateSnapshotRequestBinder(Json jsonBinder) { + super("snapshot", jsonBinder); + } + + @Override + protected String createPayload(Snapshot.Request.UpdatePayload payload) { + + checkNotNull(payload.id(), "snapshotId"); + + snapshotId = payload.id(); + + if (payload.name() != null) + requestBuilder.put("name", payload.name()); + + if (payload.description() != null) + requestBuilder.put("description", payload.description()); + + if (payload.licenceType() != null) + requestBuilder.put("licenceType", payload.licenceType()); + + if (payload.cpuHotPlug() != null) + requestBuilder.put("cpuHotPlug", payload.cpuHotPlug()); + + if (payload.cpuHotUnplug() != null) + requestBuilder.put("cpuHotUnplug", payload.cpuHotUnplug()); + + if (payload.ramHotPlug() != null) + requestBuilder.put("ramHotPlug", payload.ramHotPlug()); + + if (payload.ramHotUnplug() != null) + requestBuilder.put("ramHotUnplug", payload.ramHotUnplug()); + + if (payload.nicHotPlug() != null) + requestBuilder.put("nicHotPlug", payload.nicHotPlug()); + + if (payload.nicHotUnplug() != null) + requestBuilder.put("nicHotUnplug", payload.nicHotUnplug()); + + if (payload.discVirtioHotPlug() != null) + requestBuilder.put("discVirtioHotPlug", payload.discVirtioHotPlug()); + + if (payload.discVirtioHotUnplug() != null) + requestBuilder.put("discVirtioHotUnplug", payload.discVirtioHotUnplug()); + + if (payload.discScsiHotPlug() != null) + requestBuilder.put("discScsiHotPlug", payload.discScsiHotPlug()); + + if (payload.discScsiHotUnplug() != null) + requestBuilder.put("discScsiHotUnplug", payload.discScsiHotUnplug()); + + return jsonBinder.toJson(requestBuilder); + } + + @Override + protected <R extends HttpRequest> R createRequest(R fromRequest, String payload) { + R request = (R) fromRequest.toBuilder().replacePath(String.format("/rest/snapshots/%s", snapshotId)).build(); + return super.createRequest(request, payload); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinder.java index d18d69e..c2b8869 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinder.java @@ -16,7 +16,6 @@ */ package org.apache.jclouds.profitbricks.rest.binder.volume; -import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import javax.ws.rs.core.MediaType; @@ -24,16 +23,17 @@ import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder import org.apache.jclouds.profitbricks.rest.domain.Volume; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest.Builder; +import static com.google.common.base.Preconditions.checkNotNull; public class CreateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<Volume.Request.CreateSnapshotPayload> { - protected final Multimap<String, String> requestBuilder; + protected final Multimap<String, String> formMap; private String dataCenterId; private String volumeId; CreateSnapshotRequestBinder() { - super("snapshot"); - this.requestBuilder = HashMultimap.create(); + super("snapshot", null); + this.formMap = HashMultimap.create(); } @Override @@ -46,10 +46,10 @@ public class CreateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<V volumeId = payload.volumeId(); if (payload.name() != null) - requestBuilder.put("name", payload.name()); + formMap.put("name", payload.name()); if (payload.description() != null) - requestBuilder.put("description", payload.description()); + formMap.put("description", payload.description()); return ""; } @@ -61,7 +61,7 @@ public class CreateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<V Builder<?> reqBuilder = fromRequest.toBuilder(); - reqBuilder.addFormParams(requestBuilder); + reqBuilder.addFormParams(formMap); reqBuilder.replacePath(String.format("/rest/datacenters/%s/volumes/%s/create-snapshot", dataCenterId, volumeId)); R req = (R) reqBuilder.build(); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateVolumeRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateVolumeRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateVolumeRequestBinder.java index 76e4a3b..8cbf1a7 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateVolumeRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateVolumeRequestBinder.java @@ -27,16 +27,11 @@ import org.jclouds.json.Json; public class CreateVolumeRequestBinder extends BaseProfitBricksRequestBinder<Volume.Request.CreatePayload> { - protected final Map<String, Object> requestBuilder; - final Json jsonBinder; - private String dataCenterId; @Inject CreateVolumeRequestBinder(Json jsonBinder) { - super("volume"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("volume", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/RestoreSnapshotRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/RestoreSnapshotRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/RestoreSnapshotRequestBinder.java index ff08240..8fb5ab7 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/RestoreSnapshotRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/RestoreSnapshotRequestBinder.java @@ -16,25 +16,24 @@ */ package org.apache.jclouds.profitbricks.rest.binder.volume; -import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import javax.ws.rs.core.MediaType; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Volume; import org.jclouds.http.HttpRequest; +import static com.google.common.base.Preconditions.checkNotNull; public class RestoreSnapshotRequestBinder extends BaseProfitBricksRequestBinder<Volume.Request.RestoreSnapshotPayload> { - protected final Multimap<String, String> requestBuilder; + protected final Multimap<String, String> formMap; private String dataCenterId; private String volumeId; - private String snapshotId; RestoreSnapshotRequestBinder() { - super("snapshot"); - this.requestBuilder = HashMultimap.create(); + super("snapshot", null); + this.formMap = HashMultimap.create(); } @Override @@ -46,9 +45,8 @@ public class RestoreSnapshotRequestBinder extends BaseProfitBricksRequestBinder< dataCenterId = payload.dataCenterId(); volumeId = payload.volumeId(); - snapshotId = payload.snapshotId(); - requestBuilder.put("snapshotId", payload.snapshotId()); + formMap.put("snapshotId", payload.snapshotId()); return ""; } @@ -60,7 +58,7 @@ public class RestoreSnapshotRequestBinder extends BaseProfitBricksRequestBinder< HttpRequest.Builder<?> reqBuilder = fromRequest.toBuilder(); - reqBuilder.addFormParams(requestBuilder); + reqBuilder.addFormParams(formMap); reqBuilder.replacePath(String.format("/rest/datacenters/%s/volumes/%s/restore-snapshot", dataCenterId, volumeId)); R req = (R) reqBuilder.build(); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinder.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinder.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinder.java index 51d8027..188d28d 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinder.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinder.java @@ -18,8 +18,6 @@ package org.apache.jclouds.profitbricks.rest.binder.volume; import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; -import java.util.HashMap; -import java.util.Map; import org.apache.jclouds.profitbricks.rest.binder.BaseProfitBricksRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Volume; import org.jclouds.http.HttpRequest; @@ -27,17 +25,12 @@ import org.jclouds.json.Json; public class UpdateVolumeRequestBinder extends BaseProfitBricksRequestBinder<Volume.Request.UpdatePayload> { - protected final Map<String, Object> requestBuilder; - final Json jsonBinder; - private String dataCenterId; private String volumeId; @Inject UpdateVolumeRequestBinder(Json jsonBinder) { - super("volume"); - this.jsonBinder = jsonBinder; - this.requestBuilder = new HashMap<String, Object>(); + super("volume", jsonBinder); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Snapshot.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Snapshot.java b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Snapshot.java index 793cede..2cb3761 100644 --- a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Snapshot.java +++ b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/domain/Snapshot.java @@ -23,69 +23,148 @@ import org.jclouds.json.SerializedNames; @AutoValue public abstract class Snapshot { - public abstract String id(); - - public abstract String type(); + public abstract String id(); + + public abstract String type(); + + public abstract String href(); + + @Nullable + public abstract Metadata metadata(); + + @Nullable + public abstract Properties properties(); + + @SerializedNames({"id", "type", "href", "metadata", "properties"}) + public static Snapshot create(String id, String type, String href, Metadata metadata, Properties properties) { + return new AutoValue_Snapshot(id, type, href, metadata, properties); + } + + @AutoValue + public abstract static class Properties { + + @Nullable + public abstract String name(); + + @Nullable + public abstract String description(); + + @Nullable + public abstract Integer size(); + + @Nullable + public abstract LicenceType licenceType(); + + public abstract Location location(); - public abstract String href(); + public abstract boolean cpuHotPlug(); - @Nullable - public abstract Metadata metadata(); + public abstract boolean cpuHotUnplug(); - @Nullable - public abstract Properties properties(); + public abstract boolean ramHotPlug(); + + public abstract boolean ramHotUnplug(); + + public abstract boolean nicHotPlug(); + + public abstract boolean nicHotUnplug(); + + public abstract boolean discVirtioHotPlug(); + + public abstract boolean discVirtioHotUnplug(); + + public abstract boolean discScsiHotPlug(); + + public abstract boolean discScsiHotUnplug(); + + @SerializedNames({"name", "description", "size", "licenceType", "location", "cpuHotPlug", "cpuHotUnplug", "ramHotPlug", "ramHotUnplug", "nicHotPlug", "nicHotUnplug", "discVirtioHotPlug", "discVirtioHotUnplug", "discScsiHotPlug", "discScsiHotUnplug"}) + public static Snapshot.Properties create(String name, String description, Integer size, LicenceType licenceType, Location location, + boolean cpuHotPlug, boolean cpuHotUnplug, boolean ramHotPlug, boolean ramHotUnplug, boolean nicHotPlug, boolean nicHotUnplug, boolean discVirtioHotPlug, + boolean discVirtioHotUnplug, boolean discScsiHotPlug, boolean discScsiHotUnplug) { + + return new AutoValue_Snapshot_Properties(name, description, size, licenceType, location, cpuHotPlug, cpuHotUnplug, ramHotPlug, ramHotUnplug, nicHotPlug, nicHotUnplug, discVirtioHotPlug, discVirtioHotUnplug, discScsiHotPlug, discScsiHotUnplug); + + + } + } + + public static final class Request { - @SerializedNames({"id", "type", "href", "metadata", "properties"}) - public static Snapshot create(String id, String type, String href, Metadata metadata, Properties properties) { - return new AutoValue_Snapshot(id, type, href, metadata, properties); - } + public static UpdatePayload.Builder updatingBuilder() { + return new AutoValue_Snapshot_Request_UpdatePayload.Builder(); + } - @AutoValue - public abstract static class Properties { + @AutoValue + public abstract static class UpdatePayload { - @Nullable - public abstract String name(); + public abstract String id(); - @Nullable - public abstract String description(); + @Nullable + public abstract String name(); + + @Nullable + public abstract String description(); - @Nullable - public abstract Integer size(); + @Nullable + public abstract LicenceType licenceType(); - @Nullable - public abstract LicenceType licenceType(); - - public abstract Location location(); + @Nullable + public abstract Boolean cpuHotPlug(); - public abstract boolean cpuHotPlug(); + @Nullable + public abstract Boolean cpuHotUnplug(); - public abstract boolean cpuHotUnplug(); + @Nullable + public abstract Boolean ramHotPlug(); - public abstract boolean ramHotPlug(); + @Nullable + public abstract Boolean ramHotUnplug(); - public abstract boolean ramHotUnplug(); + @Nullable + public abstract Boolean nicHotPlug(); - public abstract boolean nicHotPlug(); + @Nullable + public abstract Boolean nicHotUnplug(); - public abstract boolean nicHotUnplug(); + @Nullable + public abstract Boolean discVirtioHotPlug(); - public abstract boolean discVirtioHotPlug(); + @Nullable + public abstract Boolean discVirtioHotUnplug(); - public abstract boolean discVirtioHotUnplug(); + @Nullable + public abstract Boolean discScsiHotPlug(); - public abstract boolean discScsiHotPlug(); + @Nullable + public abstract Boolean discScsiHotUnplug(); - public abstract boolean discScsiHotUnplug(); + @AutoValue.Builder + public abstract static class Builder { - @SerializedNames({"name", "description", "size", "licenceType", "location", "cpuHotPlug", "cpuHotUnplug", "ramHotPlug", "ramHotUnplug", "nicHotPlug", "nicHotUnplug", "discVirtioHotPlug", "discVirtioHotUnplug", "discScsiHotPlug", "discScsiHotUnplug"}) - public static Snapshot.Properties create(String name, String description, Integer size, LicenceType licenceType, Location location, - boolean cpuHotPlug, boolean cpuHotUnplug, boolean ramHotPlug, boolean ramHotUnplug, boolean nicHotPlug, boolean nicHotUnplug, boolean discVirtioHotPlug, - boolean discVirtioHotUnplug, boolean discScsiHotPlug, boolean discScsiHotUnplug) { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder description(String description); + public abstract Builder licenceType(LicenceType licenceType); + public abstract Builder cpuHotPlug(Boolean cpuHotPlug); + public abstract Builder cpuHotUnplug(Boolean cpuHotUnplug); + public abstract Builder ramHotPlug(Boolean ramHotPlug); + public abstract Builder ramHotUnplug(Boolean ramHotUnplug); + public abstract Builder nicHotPlug(Boolean nicHotPlug); + public abstract Builder nicHotUnplug(Boolean nicHotUnplug); + public abstract Builder discVirtioHotPlug(Boolean discVirtioHotPlug); + public abstract Builder discVirtioHotUnplug(Boolean discVirtioHotUnplug); + public abstract Builder discScsiHotPlug(Boolean discScsiHotPlug); + public abstract Builder discScsiHotUnplug(Boolean discScsiHotUnplug); + + abstract UpdatePayload autoBuild(); - return new AutoValue_Snapshot_Properties(name, description, size, licenceType, location, cpuHotPlug, cpuHotUnplug, ramHotPlug, ramHotUnplug, nicHotPlug, nicHotUnplug, discVirtioHotPlug, discVirtioHotUnplug, discScsiHotPlug, discScsiHotUnplug); - + public UpdatePayload build() { + return autoBuild(); + } + } + } + + } - } - } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApi.java ---------------------------------------------------------------------- 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 f1d4815..0877b48 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 @@ -19,29 +19,72 @@ package org.apache.jclouds.profitbricks.rest.features; import com.google.inject.Inject; import com.google.inject.TypeLiteral; import java.io.Closeable; +import java.util.List; import javax.inject.Named; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import org.apache.jclouds.profitbricks.rest.binder.snapshot.UpdateSnapshotRequestBinder; import org.apache.jclouds.profitbricks.rest.domain.Snapshot; +import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; import org.jclouds.Fallbacks; +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PATCH; +import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; @Path("/snapshots") @RequestFilters(BasicAuthentication.class) public interface SnapshotApi extends Closeable { + @Named("snapshot:list") + @GET + @SelectJson("items") + @Fallback(EmptyListOnNotFoundOr404.class) + List<Snapshot> list(); + + @Named("snapshot:list") + @GET + @SelectJson("items") + @Fallback(EmptyListOnNotFoundOr404.class) + List<Snapshot> list(DepthOptions options); + + @Named("snapshot:get") + @GET + @Path("/{snapshotId}") + @ResponseParser(SnapshotApi.SnapshotParser.class) + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + Snapshot get(@PathParam("snapshotId") String snapshotId); + @Named("snapshot:get") @GET - @Path("/{id}") + @Path("/{snapshotId}") @ResponseParser(SnapshotApi.SnapshotParser.class) @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Snapshot getSnapshot(@PathParam("id") String id); + Snapshot get(@PathParam("snapshotId") String snapshotId, DepthOptions options); + + @Named("snapshot:update") + @PATCH + @Path("/{snapshotId}") + @MapBinder(UpdateSnapshotRequestBinder.class) + @ResponseParser(SnapshotApi.SnapshotParser.class) + @Produces("application/vnd.profitbricks.partial-properties+json") + Snapshot update(@PayloadParam("snapshot") Snapshot.Request.UpdatePayload payload); + + @Named("snapshot:delete") + @DELETE + @Path("/{snapshotId}") + @Fallback(Fallbacks.VoidOnNotFoundOr404.class) + void delete(@PathParam("snapshotId") String snapshotId); static final class SnapshotParser extends ParseJson<Snapshot> { http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinderTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinderTest.java new file mode 100644 index 0000000..0ad5673 --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/snapshot/UpdateSnapshotRequestBinderTest.java @@ -0,0 +1,65 @@ +/* + * 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.apache.jclouds.profitbricks.rest.binder.snapshot; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import java.util.HashMap; +import org.apache.jclouds.profitbricks.rest.domain.Snapshot; +import org.jclouds.http.HttpRequest; +import org.jclouds.json.Json; +import org.jclouds.json.config.GsonModule; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "UpdateSnapshotRequestBinderTest") +public class UpdateSnapshotRequestBinderTest { + + @Test + public void testUpdatePayload() { + + Injector injector = Guice.createInjector(new GsonModule()); + UpdateSnapshotRequestBinder binder = injector.getInstance(UpdateSnapshotRequestBinder.class); + + Snapshot.Request.UpdatePayload payload = Snapshot.Request.updatingBuilder() + .id("some-id") + .name("new-snapshot-name") + .description("description...") + .build(); + + String actual = binder.createPayload(payload); + + HttpRequest request = binder.createRequest( + HttpRequest.builder().method("POST").endpoint("http://test.com").build(), + actual + ); + + assertEquals(request.getEndpoint().getPath(), "/rest/snapshots/some-id"); + assertNotNull(actual, "Binder returned null payload"); + + Json json = injector.getInstance(Json.class); + + HashMap<String, Object> expectedPayload = new HashMap<String, Object>(); + + expectedPayload.put("name", "new-snapshot-name"); + expectedPayload.put("description", "description..."); + + assertEquals(actual, json.toJson(expectedPayload)); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiLiveTest.java index a7caaff..78e86ab 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ImageApiLiveTest.java @@ -18,9 +18,10 @@ package org.apache.jclouds.profitbricks.rest.features; import java.util.List; import org.apache.jclouds.profitbricks.rest.domain.Image; +import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; -import static org.testng.Assert.assertEquals; 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; @@ -28,24 +29,27 @@ import static org.testng.Assert.assertTrue; @Test(groups = "live", testName = "ImageApiLiveTest") public class ImageApiLiveTest extends BaseProfitBricksLiveTest { - String testImageId = "7cb4b3a3-50c3-11e5-b789-52540066fee9"; + private String testImageId; + private String testImageName; - @Test + @Test(dependsOnMethods = "testList") public void testGetImage() { Image image = imageApi().getImage(testImageId); assertNotNull(image); assertEquals(image.id(), testImageId); - assertEquals(image.properties().name(), "ubuntu-14.04.3-server-amd64.iso"); + assertEquals(image.properties().name(), testImageName); } @Test public void testList() { - List<Image> images = imageApi().getList(); + List<Image> images = imageApi().getList(new DepthOptions().depth(5)); assertNotNull(images); assertFalse(images.isEmpty()); assertTrue(images.size() > 1); + testImageId = images.get(0).id(); + testImageName = images.get(0).properties().name(); } private ImageApi imageApi() { http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java ---------------------------------------------------------------------- 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 949588b..6117cf7 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 @@ -37,10 +37,10 @@ import static org.testng.Assert.assertTrue; @Test(groups = "live", testName = "ServerApiLiveTest") public class ServerApiLiveTest extends BaseProfitBricksLiveTest { - DataCenter dataCenter; - Server testServer; - Image attachedCdrom; - Volume attachedVolume; + private DataCenter dataCenter; + private Server testServer; + private Image attachedCdrom; + private Volume attachedVolume; @BeforeClass public void setupTest() { @@ -222,7 +222,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { } private void assertCdromAvailable(Server server, String cdRomId) { - assertRandom(new Predicate<String>() { + assertPredicate(new Predicate<String>() { @Override public boolean apply(String args) { String[] params = args.split(","); @@ -237,7 +237,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { } private void assertCdromRemoved(Server server, String cdRomId) { - assertRandom(new Predicate<String>() { + assertPredicate(new Predicate<String>() { @Override public boolean apply(String args) { String[] params = args.split(","); @@ -247,7 +247,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { } private void assertVolumeAttached(Server server, String volumeId) { - assertRandom(new Predicate<String>() { + assertPredicate(new Predicate<String>() { @Override public boolean apply(String args) { String[] params = args.split(","); @@ -262,7 +262,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { } private void assertVolumeDetached(Server server, String volumeId) { - assertRandom(new Predicate<String>() { + assertPredicate(new Predicate<String>() { @Override public boolean apply(String args) { String[] params = args.split(","); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java new file mode 100644 index 0000000..d4703a9 --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java @@ -0,0 +1,173 @@ +/* + * 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.apache.jclouds.profitbricks.rest.features; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import java.util.List; +import org.apache.jclouds.profitbricks.rest.domain.DataCenter; +import org.apache.jclouds.profitbricks.rest.domain.LicenceType; +import org.apache.jclouds.profitbricks.rest.domain.Snapshot; +import org.apache.jclouds.profitbricks.rest.domain.State; +import org.apache.jclouds.profitbricks.rest.domain.Volume; +import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; +import org.testng.annotations.Test; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +@Test(groups = "live", testName = "SnapshotApiLiveTest") +public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { + + private DataCenter dataCenter; + private Volume testVolume; + private Snapshot testSnapshot; + + @BeforeClass + public void setupTest() { + dataCenter = createDataCenter(); + assertDataCenterAvailable(dataCenter); + + testVolume = api.volumeApi().createVolume( + Volume.Request.creatingBuilder() + .dataCenterId(dataCenter.id()) + .name("jclouds-volume") + .size(3) + .licenceType(LicenceType.LINUX) + .build() + ); + + assertNotNull(testVolume); + assertVolumeAvailable(testVolume); + + testSnapshot = api.volumeApi().createSnapshot( + Volume.Request.createSnapshotBuilder() + .dataCenterId(testVolume.dataCenterId()) + .volumeId(testVolume.id()) + .name("test-snapshot") + .description("snapshot desc...") + .build()); + + assertSnapshotAvailable(testSnapshot); + } + + @AfterClass(alwaysRun = true) + public void teardownTest() { + if (dataCenter != null) + deleteDataCenter(dataCenter.id()); + } + + @Test + public void testList() { + List<Snapshot> snapshots = snapshotApi().list(); + + assertNotNull(snapshots); + assertFalse(snapshots.isEmpty()); + + assertTrue(Iterables.any(snapshots, new Predicate<Snapshot>() { + @Override public boolean apply(Snapshot input) { + return input.id().equals(testSnapshot.id()); + } + })); + } + + @Test + public void testGetSnapshot() { + Snapshot snapshot = snapshotApi().get(testSnapshot.id()); + + assertNotNull(snapshot); + assertEquals(snapshot.id(), testSnapshot.id()); + assertEquals(snapshot.properties().name(), "test-snapshot"); + } + + @Test(dependsOnMethods = "testGetSnapshot") + public void testUpdateSnapshot() { + Snapshot snapshot = snapshotApi().update( + Snapshot.Request.updatingBuilder() + .id(testSnapshot.id()) + .name("test-snapshot new name") + .build() + ); + + assertVolumeAvailable(testVolume); + assertEquals(snapshot.properties().name(), "test-snapshot new name"); + } + + @Test(dependsOnMethods = "testUpdateSnapshot") + public void testDeleteSnapshot() { + api.volumeApi().deleteVolume(testVolume.dataCenterId(), testVolume.id()); + assertVolumeRemoved(testVolume); + snapshotApi().delete(testSnapshot.id()); + assertSnapshotRemoved(testSnapshot); + } + + private SnapshotApi snapshotApi() { + return api.snapshotApi(); + } + + private void assertVolumeAvailable(Volume volume) { + assertPredicate(new Predicate<VolumeRef>() { + @Override + public boolean apply(VolumeRef volumeRef) { + Volume volume = api.volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()); + + if (volume == null || volume.metadata() == null) + return false; + + return volume.metadata().state() == State.AVAILABLE; + } + }, VolumeRef.create(volume.dataCenterId(), volume.id())); + } + + private void assertVolumeRemoved(Volume volume) { + assertPredicate(new Predicate<VolumeRef>() { + @Override + public boolean apply(VolumeRef volumeRef) { + return api.volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()) == null; + } + }, VolumeRef.create(volume.dataCenterId(), volume.id())); + } + + private void assertSnapshotAvailable(Snapshot snapshot) { + assertPredicate(new Predicate<String>() { + @Override + public boolean apply(String id) { + Snapshot snapshot = api.snapshotApi().get(id); + + if (snapshot == null || snapshot.metadata() == null) + return false; + + return snapshot.metadata().state() == State.AVAILABLE; + } + }, snapshot.id()); + } + + private void assertSnapshotRemoved(Snapshot snapshot) { + assertPredicate(new Predicate<String>() { + @Override + public boolean apply(String id) { + return snapshotApi().get(id) == null; + } + }, snapshot.id()); + } + + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java ---------------------------------------------------------------------- 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 new file mode 100644 index 0000000..de944c2 --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java @@ -0,0 +1,179 @@ +/* + * 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.apache.jclouds.profitbricks.rest.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import java.util.List; +import org.apache.jclouds.profitbricks.rest.domain.Snapshot; +import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "SnapshotApiMockTest", singleThreaded = true) +public class SnapshotApiMockTest extends BaseProfitBricksApiMockTest { + + @Test + public void testGetList() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/snapshot/list.json")) + ); + + List<Snapshot> list = snapshotApi().list(); + + assertNotNull(list); + assertEquals(list.size(), 9); + assertEquals(list.get(0).properties().name(), "snapshot desc..."); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots"); + } + + @Test + public void testGetListWithDepth() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/snapshot/list-depth-5.json")) + ); + + List<Snapshot> list = snapshotApi().list(new DepthOptions().depth(5)); + + assertNotNull(list); + assertEquals(list.size(), 3); + assertEquals(list.get(0).properties().name(), "test snapshot"); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots?depth=5"); + } + + @Test + public void testGetListWith404() throws InterruptedException { + server.enqueue(response404()); + List<Snapshot> list = snapshotApi().list(); + assertTrue(list.isEmpty()); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots"); + } + + @Test + public void testGetListWithDepth404() throws InterruptedException { + server.enqueue(response404()); + List<Snapshot> list = snapshotApi().list(new DepthOptions().depth(5)); + assertTrue(list.isEmpty()); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots?depth=5"); + } + + @Test + public void testGetSnapshot() throws InterruptedException { + MockResponse response = new MockResponse(); + response.setBody(stringFromResource("/snapshot/get.json")); + response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + + server.enqueue(response); + + Snapshot snapshot = snapshotApi().get("some-id"); + + assertNotNull(snapshot); + assertEquals(snapshot.properties().name(), "snapshot desc..."); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots/some-id"); + } + + @Test + 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"); + + server.enqueue(response); + + Snapshot snapshot = snapshotApi().get("some-id", new DepthOptions().depth(5)); + + assertNotNull(snapshot); + assertEquals(snapshot.properties().name(), "test snapshot 2"); + + assertEquals(this.server.getRequestCount(), 1); + assertSent(this.server, "GET", "/snapshots/some-id?depth=5"); + } + + + public void testGetSnapshotWith404() throws InterruptedException { + server.enqueue(response404()); + + Snapshot snapshot = snapshotApi().get("some-id"); + + assertEquals(snapshot, null); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots/some-id"); + } + + public void testGetSnapshotWithDepth404() throws InterruptedException { + server.enqueue(response404()); + + Snapshot snapshot = snapshotApi().get("some-id", new DepthOptions().depth(5)); + + assertEquals(snapshot, null); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/snapshots/some-id?depth=5"); + } + + @Test + public void testUpdate() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/snapshot/get.json")) + ); + + api.snapshotApi().update( + Snapshot.Request.updatingBuilder() + .id("some-id") + .name("new-snapshot-name") + .description("description...") + .build()); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "PATCH", "/rest/snapshots/some-id", "{\"name\": \"new-snapshot-name\", \"description\": \"description...\"}"); + } + + @Test + public void testDelete() throws InterruptedException { + server.enqueue(response204()); + + snapshotApi().delete("some-id"); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "DELETE", "/snapshots/some-id"); + } + + @Test + public void testDeleteWith404() throws InterruptedException { + server.enqueue(response404()); + + snapshotApi().delete("some-id"); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "DELETE", "/snapshots/some-id"); + } + + private SnapshotApi snapshotApi() { + return api.snapshotApi(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java index 98a9693..6829fc1 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java @@ -35,9 +35,9 @@ import static org.testng.Assert.assertNotNull; @Test(groups = "live", testName = "VolumeApiLiveTest") public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { - DataCenter dataCenter; - Volume testVolume; - Snapshot testSnapshot; + private DataCenter dataCenter; + private Volume testVolume; + private Snapshot testSnapshot; @BeforeClass public void setupTest() { @@ -129,10 +129,11 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { public void testDeleteVolume() { volumeApi().deleteVolume(testVolume.dataCenterId(), testVolume.id()); assertVolumeRemoved(testVolume); + api.snapshotApi().delete(testSnapshot.id()); } private void assertVolumeAvailable(Volume volume) { - assertRandom(new Predicate<VolumeRef>() { + assertPredicate(new Predicate<VolumeRef>() { @Override public boolean apply(VolumeRef volumeRef) { Volume volume = volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()); @@ -146,7 +147,7 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { } private void assertVolumeRemoved(Volume volume) { - assertRandom(new Predicate<VolumeRef>() { + assertPredicate(new Predicate<VolumeRef>() { @Override public boolean apply(VolumeRef volumeRef) { return volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()) == null; @@ -155,10 +156,10 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { } private void assertSnapshotAvailable(Snapshot snapshot) { - assertRandom(new Predicate<String>() { + assertPredicate(new Predicate<String>() { @Override public boolean apply(String id) { - Snapshot snapshot = api.snapshotApi().getSnapshot(id); + Snapshot snapshot = api.snapshotApi().get(id); if (snapshot == null || snapshot.metadata() == null) return false; http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java ---------------------------------------------------------------------- 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 75eefc7..0a42a4b 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 @@ -120,7 +120,7 @@ public class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> { return injector.getInstance(ProfitBricksApi.class); } - protected <T> void assertRandom(Predicate<T> check, T arguments) { + protected <T> void assertPredicate(Predicate<T> check, T arguments) { ComputeConstants c = computeConstants; Predicate<T>checkPoll = Predicates2.retry(check, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); assertTrue(checkPoll.apply(arguments), "Random check failed in the configured timeout"); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/resources/snapshot/get-depth-5.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/snapshot/get-depth-5.json b/profitbricks-rest/src/test/resources/snapshot/get-depth-5.json new file mode 100644 index 0000000..c1a4e10 --- /dev/null +++ b/profitbricks-rest/src/test/resources/snapshot/get-depth-5.json @@ -0,0 +1,30 @@ +{ + "id": "a0327de8-65e7-4524-bc22-ad0328bbdb00", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/a0327de8-65e7-4524-bc22-ad0328bbdb00", + "metadata": { + "createdDate": "2016-02-10T13:42:52Z", + "createdBy": "[email protected]", + "etag": "3e7408590a6b4093989e4c94d69ef934", + "lastModifiedDate": "2016-02-10T13:42:52Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "test snapshot 2", + "description": "Created from \"apache-volume\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/resources/snapshot/get.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/snapshot/get.json b/profitbricks-rest/src/test/resources/snapshot/get.json new file mode 100644 index 0000000..6045962 --- /dev/null +++ b/profitbricks-rest/src/test/resources/snapshot/get.json @@ -0,0 +1,30 @@ +{ + "id": "615458b6-55cc-4907-a700-24b6bc1bf8ae", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/615458b6-55cc-4907-a700-24b6bc1bf8ae", + "metadata": { + "createdDate": "2015-12-23T22:03:31Z", + "createdBy": "[email protected]", + "etag": "fbed4e509c2704919ac05f185377a95d", + "lastModifiedDate": "2015-12-23T22:03:31Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/resources/snapshot/list-depth-5.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/snapshot/list-depth-5.json b/profitbricks-rest/src/test/resources/snapshot/list-depth-5.json new file mode 100644 index 0000000..8933d04 --- /dev/null +++ b/profitbricks-rest/src/test/resources/snapshot/list-depth-5.json @@ -0,0 +1,97 @@ +{ + "id": "snapshots", + "type": "collection", + "href": "https://api.profitbricks.com/rest/snapshots", + "items": [ + { + "id": "615458b6-55cc-4907-a700-24b6bc1bf8ae", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/615458b6-55cc-4907-a700-24b6bc1bf8ae", + "metadata": { + "createdDate": "2015-12-23T22:03:31Z", + "createdBy": "[email protected]", + "etag": "fbed4e509c2704919ac05f185377a95d", + "lastModifiedDate": "2015-12-23T22:03:31Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "test snapshot", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "a0327de8-65e7-4524-bc22-ad0328bbdb00", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/a0327de8-65e7-4524-bc22-ad0328bbdb00", + "metadata": { + "createdDate": "2016-02-10T13:42:52Z", + "createdBy": "[email protected]", + "etag": "3e7408590a6b4093989e4c94d69ef934", + "lastModifiedDate": "2016-02-10T13:42:52Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-volume\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "7e3d133f-227d-41dd-84af-a47d6b6033d9", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/7e3d133f-227d-41dd-84af-a47d6b6033d9", + "metadata": { + "createdDate": "2015-12-23T21:05:05Z", + "createdBy": "[email protected]", + "etag": "565e62028d0046a55f38289a8dd87214", + "lastModifiedDate": "2015-12-23T21:05:05Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ca57d90d/profitbricks-rest/src/test/resources/snapshot/list.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/snapshot/list.json b/profitbricks-rest/src/test/resources/snapshot/list.json new file mode 100644 index 0000000..0af7d22 --- /dev/null +++ b/profitbricks-rest/src/test/resources/snapshot/list.json @@ -0,0 +1,277 @@ +{ + "id": "snapshots", + "type": "collection", + "href": "https://api.profitbricks.com/rest/snapshots", + "items": [ + { + "id": "615458b6-55cc-4907-a700-24b6bc1bf8ae", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/615458b6-55cc-4907-a700-24b6bc1bf8ae", + "metadata": { + "createdDate": "2015-12-23T22:03:31Z", + "createdBy": "[email protected]", + "etag": "fbed4e509c2704919ac05f185377a95d", + "lastModifiedDate": "2015-12-23T22:03:31Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "c2dad888-5b9f-4b56-995c-59d88bfb633a", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/c2dad888-5b9f-4b56-995c-59d88bfb633a", + "metadata": { + "createdDate": "2015-12-23T21:27:48Z", + "createdBy": "[email protected]", + "etag": "19f763993d68594da810602235156954", + "lastModifiedDate": "2015-12-23T21:27:48Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "1c93b2de-0590-4c57-b1a8-e31f5641535b", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/1c93b2de-0590-4c57-b1a8-e31f5641535b", + "metadata": { + "createdDate": "2015-12-23T22:10:59Z", + "createdBy": "[email protected]", + "etag": "b275c96e3c24bcfc6596c9cb223d5075", + "lastModifiedDate": "2015-12-23T22:10:59Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "b9bc98eb-85ec-49f1-b0d5-9e0485464660", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/b9bc98eb-85ec-49f1-b0d5-9e0485464660", + "metadata": { + "createdDate": "2015-12-23T21:59:54Z", + "createdBy": "[email protected]", + "etag": "515f1fb191a5731b11aeb0c7ddce479c", + "lastModifiedDate": "2015-12-23T21:59:54Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "7e3d133f-227d-41dd-84af-a47d6b6033d9", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/7e3d133f-227d-41dd-84af-a47d6b6033d9", + "metadata": { + "createdDate": "2015-12-23T21:05:05Z", + "createdBy": "[email protected]", + "etag": "565e62028d0046a55f38289a8dd87214", + "lastModifiedDate": "2015-12-23T21:05:05Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "07cd6506-144d-4235-8900-c216847a65c9", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/07cd6506-144d-4235-8900-c216847a65c9", + "metadata": { + "createdDate": "2015-12-23T21:50:15Z", + "createdBy": "[email protected]", + "etag": "a1144aae213352ec4933f8da48d7c64b", + "lastModifiedDate": "2015-12-23T21:50:15Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "9b5379bb-81f3-4d51-90a9-ca8a3d3a716c", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/9b5379bb-81f3-4d51-90a9-ca8a3d3a716c", + "metadata": { + "createdDate": "2015-12-23T21:01:36Z", + "createdBy": "[email protected]", + "etag": "1d292da754fd120bbe5457c6b75a99c7", + "lastModifiedDate": "2015-12-23T21:01:36Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "4e250428-c67a-4bb1-8147-fcea4cead29b", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/4e250428-c67a-4bb1-8147-fcea4cead29b", + "metadata": { + "createdDate": "2015-12-23T21:13:02Z", + "createdBy": "[email protected]", + "etag": "bf671ae278ffa495340e3ab7eae09a12", + "lastModifiedDate": "2015-12-23T21:13:02Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + }, + { + "id": "dbf0c1ea-9cd0-4a89-ac0c-81527831f3bf", + "type": "snapshot", + "href": "https://api.profitbricks.com/rest/snapshots/dbf0c1ea-9cd0-4a89-ac0c-81527831f3bf", + "metadata": { + "createdDate": "2015-12-23T21:28:52Z", + "createdBy": "[email protected]", + "etag": "93700a48fcab1a962e00fa06bd352650", + "lastModifiedDate": "2015-12-23T21:28:52Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "snapshot desc...", + "description": "Created from \"apache-node\" in Data Center \"test-data-center\"", + "location": "us/lasdev", + "size": 3, + "cpuHotPlug": false, + "cpuHotUnplug": false, + "ramHotPlug": false, + "ramHotUnplug": false, + "nicHotPlug": false, + "nicHotUnplug": false, + "discVirtioHotPlug": false, + "discVirtioHotUnplug": false, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX" + } + } + ] +} \ No newline at end of file
