Add GlobalHost[Async]Client.deleteCluster()

This commit is contained in:
Richard Downer 2012-01-12 15:38:45 +02:00
parent 7284d7db2f
commit 17fb7b55d0
3 changed files with 32 additions and 0 deletions

View File

@ -217,4 +217,15 @@ public interface GlobalHostAsyncClient {
@SelectJson("cluster") @SelectJson("cluster")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Void> updateClusterPassword(@QueryParam("clusterid") long clusterId, @QueryParam("username") String username, @QueryParam("password") String password); ListenableFuture<Void> 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<Void> deleteCluster(@QueryParam("id") long clusterId);
} }

View File

@ -163,4 +163,12 @@ public interface GlobalHostClient {
* @param password the password for the cluster * @param password the password for the cluster
*/ */
void updateClusterPassword(long clusterId, String username, String password); void updateClusterPassword(long clusterId, String username, String password);
/**
* Deletes a cluster.
*
* @param clusterId the cluster ID
*/
void deleteCluster(long clusterId);
} }

View File

@ -316,6 +316,19 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
requestSendsResponse(request, response).updateClusterPassword(1, "fred", "sekrit"); 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.<String, String>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) { private Date makeDate(int year, int month, int date, int hour, int minute, int second, String timeZoneName) {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneName)); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneName));
cal.set(Calendar.YEAR, year); cal.set(Calendar.YEAR, year);