diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java index 03b2e5ef86..867134692c 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotAsyncClient.java @@ -25,10 +25,13 @@ import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.cloudstack.options.CreateSnapshotOptions; import org.jclouds.cloudstack.options.ListSnapshotsOptions; import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import javax.ws.rs.Consumes; @@ -75,6 +78,20 @@ public interface SnapshotAsyncClient { @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture> listSnapshots(ListSnapshotsOptions... options); + /** + * Gets a snapshot by its ID. + * + * @param id the snapshot ID + * @return the snapshot with the requested ID + */ + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "command", values = "listSnapshots") + @SelectJson("snapshot") + @OnlyElement + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getSnapshot(@QueryParam("id") long id); + /** * Deletes a snapshot of a disk volume. * diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotClient.java index 7c721b529f..97e9a6d97d 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotClient.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SnapshotClient.java @@ -55,6 +55,14 @@ public interface SnapshotClient { */ Set listSnapshots(ListSnapshotsOptions... options); + /** + * Gets a snapshot by its ID. + * + * @param id the snapshot ID + * @return the snapshot with the requested ID + */ + Snapshot getSnapshot(long id); + /** * Deletes a snapshot of a disk volume. * diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java index 93d4c01bf5..7b1e31b85b 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java @@ -18,15 +18,18 @@ */ package org.jclouds.cloudstack.features; +import com.google.common.base.Functions; import com.google.inject.TypeLiteral; import org.jclouds.cloudstack.domain.Snapshot; import org.jclouds.cloudstack.options.CreateSnapshotOptions; import org.jclouds.cloudstack.options.ListSnapshotsOptions; +import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -92,6 +95,23 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest