From 17fb7b55d036772932206d641e5464e03a31e109 Mon Sep 17 00:00:00 2001 From: Richard Downer Date: Thu, 12 Jan 2012 15:38:45 +0200 Subject: [PATCH] Add GlobalHost[Async]Client.deleteCluster() --- .../cloudstack/features/GlobalHostAsyncClient.java | 11 +++++++++++ .../cloudstack/features/GlobalHostClient.java | 8 ++++++++ .../features/GlobalHostClientExpectTest.java | 13 +++++++++++++ 3 files changed, 32 insertions(+) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java index be0c3a9a79..7085302d30 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java @@ -217,4 +217,15 @@ public interface GlobalHostAsyncClient { @SelectJson("cluster") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture updateClusterPassword(@QueryParam("clusterid") long clusterId, @QueryParam("username") String username, @QueryParam("password") String password); + + /** + * Deletes a cluster. + * + * @param clusterId the cluster ID + */ + @GET + @QueryParams(keys = "command", values = "deleteCluster") + @Consumes(MediaType.APPLICATION_JSON) + ListenableFuture deleteCluster(@QueryParam("id") long clusterId); + } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java index f1b042ef53..7345263990 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java @@ -163,4 +163,12 @@ public interface GlobalHostClient { * @param password the password for the cluster */ void updateClusterPassword(long clusterId, String username, String password); + + /** + * Deletes a cluster. + * + * @param clusterId the cluster ID + */ + void deleteCluster(long clusterId); + } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java index 57b0a7414f..616b135a5e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java @@ -316,6 +316,19 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe requestSendsResponse(request, response).updateClusterPassword(1, "fred", "sekrit"); } + @Test + public void testDeleteClusterWhenResponseIs2xx() { + HttpRequest request = HttpRequest.builder() + .method("GET") + .endpoint(URI.create("http://localhost:8080/client/api?response=json&command=deleteCluster&id=1&apiKey=identity&signature=CKH26MFgKGY7Sosd17LjBMNa3AI%3D")) + .headers(ImmutableMultimap.builder().put("Accept", "application/json").build()) + .build(); + HttpResponse response = HttpResponse.builder() + .statusCode(200).build(); + + requestSendsResponse(request, response).deleteCluster(1); + } + private Date makeDate(int year, int month, int date, int hour, int minute, int second, String timeZoneName) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneName)); cal.set(Calendar.YEAR, year);