Skip to content

Commit

Permalink
JCLOUDS-1457 - Add Clean Server operation to ServerApi.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Flanagan authored and nacx committed Oct 18, 2018
1 parent eb99002 commit 54249bd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public enum State {

NORMAL, FAILED_ADD, FAILED_CHANGE, FAILED_DELETE, PENDING_DELETE, DELETED, UNRECOGNIZED, PENDING_CHANGE;
NORMAL, FAILED_ADD, FAILED_CHANGE, FAILED_DELETE, PENDING_DELETE, DELETED, UNRECOGNIZED, PENDING_CHANGE, PENDING_CLEAN, REQUIRES_SUPPORT;

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.jclouds.dimensiondata.cloudcontrol.domain;

import com.google.auto.value.AutoValue;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

import java.util.Date;
Expand All @@ -35,6 +36,7 @@ public static Builder builder() {

public abstract String name();

@Nullable
public abstract String description();

public abstract String datacenterId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ String cloneServer(@PayloadParam("id") String id, @PayloadParam("imageName") Str
@MapBinder(BindToJsonPayload.class)
void startServer(@PayloadParam("id") String id);

/**
* Operation for cleaning servers with FAILED_ADD state
*
* @see org.jclouds.dimensiondata.cloudcontrol.domain.State.FAILED_ADD
*/
@Named("server:cleanServer")
@POST
@Path("/cleanServer")
@Produces(MediaType.APPLICATION_JSON)
@MapBinder(BindToJsonPayload.class)
void cleanServer(@PayloadParam("id") String id);

@Named("server:shutdown")
@POST
@Path("/shutdownServer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ public void testStartServer() throws Exception {
assertBodyContains(recordedRequest, "{\"id\":\"12345\"}");
}

public void testCleanServer() throws Exception {
server.enqueue(jsonResponse("/cleanServer.json"));
serverApi().cleanServer("12345");
final RecordedRequest recordedRequest = assertSent(POST,
"/caas/2.4/6ac1e746-b1ea-4da5-a24e-caf1a978789d/server/cleanServer");
assertBodyContains(recordedRequest, "{\"id\":\"12345\"}");
}

private ServerApi serverApi() {
return api.getServerApi();
}
Expand Down
9 changes: 9 additions & 0 deletions dimensiondata/src/test/resources/cleanServer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"operation": "CLEAN_SERVER",
"responseCode": "IN_PROGRESS",
"message": "Request to Clean Server has been accepted. Please use appropriate Get or List API for status.",
"info": [],
"warning": [],
"error": [],
"requestId": "na9_20160321T074626030-0400_7e9fffe7-190b-46f2-9107-9d52fe57d0ad"
}

0 comments on commit 54249bd

Please sign in to comment.