Add GlobalHost[Async]Client.cancelHostMaintenance()

This commit is contained in:
Richard Downer 2012-01-12 14:31:03 +02:00
parent b3bb99da88
commit 528fa0ae5a
4 changed files with 36 additions and 0 deletions

View File

@ -126,6 +126,18 @@ public interface GlobalHostAsyncClient {
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> prepareHostForMaintenance(@QueryParam("id") long hostId);
/**
* Cancels host maintenance.
*
* @param hostId the host ID
* @return a job reference number for tracking this asynchronous job.
*/
@GET
@QueryParams(keys = "command", values = "cancelHostMaintenance")
@SelectJson("jobid")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> cancelHostMaintenance(@QueryParam("id") long hostId);
/**
* @see GlobalHostClient#listClusters
*/

View File

@ -98,6 +98,14 @@ public interface GlobalHostClient {
*/
Long prepareHostForMaintenance(long hostId);
/**
* Cancels host maintenance.
*
* @param hostId the host ID
* @return a job reference number for tracking this asynchronous job.
*/
Long cancelHostMaintenance(long hostId);
/**
* Lists clusters
*

View File

@ -180,6 +180,21 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
assertEquals(actual, Long.valueOf(2036L));
}
@Test
public void testCancelHostMaintenanceWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()
.method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=cancelHostMaintenance&id=1&apiKey=identity&signature=9RduzuBoyRZKNTzAoVqUo9gRTfk%3D"))
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
.build();
HttpResponse response = HttpResponse.builder()
.payload(payloadFromResource("/cancelhostmaintenanceresponse.json"))
.statusCode(200).build();
Long actual = requestSendsResponse(request, response).cancelHostMaintenance(1);
assertEquals(actual, Long.valueOf(2036L));
}
@Test
public void testListClustersWhenResponseIs2xx() {
HttpRequest request = HttpRequest.builder()

View File

@ -0,0 +1 @@
{ "cancelhostmaintenanceresponse" : {"warning":"this test data is fabricated","jobid":2036,"id":2017} }