mirror of https://github.com/apache/jclouds.git
Add SnapshotClient.getSnapshot(long id) et al to Cloudstack
This commit is contained in:
parent
16771961e1
commit
48f05f3aed
|
@ -25,10 +25,13 @@ import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
import org.jclouds.cloudstack.options.CreateSnapshotOptions;
|
import org.jclouds.cloudstack.options.CreateSnapshotOptions;
|
||||||
import org.jclouds.cloudstack.options.ListSnapshotsOptions;
|
import org.jclouds.cloudstack.options.ListSnapshotsOptions;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.OnlyElement;
|
||||||
import org.jclouds.rest.annotations.QueryParams;
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.jclouds.rest.annotations.Unwrap;
|
import org.jclouds.rest.annotations.Unwrap;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
@ -75,6 +78,20 @@ public interface SnapshotAsyncClient {
|
||||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
ListenableFuture<Set<Snapshot>> listSnapshots(ListSnapshotsOptions... options);
|
ListenableFuture<Set<Snapshot>> 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<Snapshot> getSnapshot(@QueryParam("id") long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a snapshot of a disk volume.
|
* Deletes a snapshot of a disk volume.
|
||||||
*
|
*
|
||||||
|
|
|
@ -55,6 +55,14 @@ public interface SnapshotClient {
|
||||||
*/
|
*/
|
||||||
Set<Snapshot> listSnapshots(ListSnapshotsOptions... options);
|
Set<Snapshot> 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.
|
* Deletes a snapshot of a disk volume.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,15 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import org.jclouds.cloudstack.domain.Snapshot;
|
import org.jclouds.cloudstack.domain.Snapshot;
|
||||||
import org.jclouds.cloudstack.options.CreateSnapshotOptions;
|
import org.jclouds.cloudstack.options.CreateSnapshotOptions;
|
||||||
import org.jclouds.cloudstack.options.ListSnapshotsOptions;
|
import org.jclouds.cloudstack.options.ListSnapshotsOptions;
|
||||||
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -92,6 +95,23 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetSnapshot() throws NoSuchMethodException {
|
||||||
|
Method method = SnapshotAsyncClient.class.getMethod("getSnapshot", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&id=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest,
|
||||||
|
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
}
|
||||||
|
|
||||||
public void testListSnapshotsOptions() throws NoSuchMethodException {
|
public void testListSnapshotsOptions() throws NoSuchMethodException {
|
||||||
Method method = SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class);
|
Method method = SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, ListSnapshotsOptions.Builder.accountInDomain("acc", 7).id(5).intervalType(Snapshot.SnapshotIntervalType.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.SnapshotType.RECURRING).volumeId(11));
|
HttpRequest httpRequest = processor.createRequest(method, ListSnapshotsOptions.Builder.accountInDomain("acc", 7).id(5).intervalType(Snapshot.SnapshotIntervalType.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.SnapshotType.RECURRING).volumeId(11));
|
||||||
|
|
Loading…
Reference in New Issue