mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-07 21:48:30 +00:00
Add delete single execution
This commit is contained in:
parent
b1c0a45da6
commit
e092ccdb13
4 changed files with 93 additions and 0 deletions
|
@ -1672,6 +1672,23 @@ public class RundeckClient implements Serializable {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a single execution, identified by the given ID
|
||||
*
|
||||
* @param executionId identifier for the execution - mandatory
|
||||
* @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
* @throws IllegalArgumentException if the executionId is null
|
||||
*/
|
||||
public void deleteExecution(final Long executionId)
|
||||
throws RundeckApiException, RundeckApiLoginException,
|
||||
RundeckApiTokenException, IllegalArgumentException
|
||||
{
|
||||
AssertUtil.notNull(executionId, "executionId is mandatory to abort an execution !");
|
||||
new ApiCall(this).delete(new ApiPathBuilder("/execution/", executionId.toString()));
|
||||
}
|
||||
|
||||
/*
|
||||
* History
|
||||
*/
|
||||
|
|
|
@ -1572,6 +1572,42 @@ public class RundeckClientTest {
|
|||
response.getFailures().get(1).getMessage()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* delete single execution success
|
||||
*/
|
||||
@Test
|
||||
@Betamax(tape = "delete_execution_success", mode = TapeMode.READ_ONLY)
|
||||
public void deleteExecutionSuccess() throws Exception {
|
||||
final RundeckClient client = createClient(TEST_TOKEN_8, 12);
|
||||
client.deleteExecution(643L);
|
||||
}
|
||||
/**
|
||||
* delete single execution failure (does not exist)
|
||||
*/
|
||||
@Test
|
||||
@Betamax(tape = "delete_execution_failure", mode = TapeMode.READ_ONLY)
|
||||
public void deleteExecutionFailure() throws Exception {
|
||||
final RundeckClient client = createClient(TEST_TOKEN_8, 12);
|
||||
try {
|
||||
client.deleteExecution(640L);
|
||||
Assert.fail();
|
||||
} catch (RundeckApiException.RundeckApiHttpStatusException e) {
|
||||
Assert.assertEquals(404, e.getStatusCode());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* delete single execution null input
|
||||
*/
|
||||
@Test
|
||||
public void deleteExecutionNullInput() throws Exception {
|
||||
final RundeckClient client = createClient(TEST_TOKEN_8, 12);
|
||||
try {
|
||||
client.deleteExecution(null);
|
||||
Assert.fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
}
|
||||
}
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// not that you can put whatever here, because we don't actually connect to the RunDeck instance
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
!tape
|
||||
name: delete_execution_failure
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:45:47.952Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/execution/640
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1eynpbisggwsy18ax352yya8k0;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
body: "<result error='true' apiversion='12'>\n <error code='api.error.item.doesnotexist'>\n <message>Execution ID does not exist: 640</message>\n </error>\n</result>"
|
|
@ -0,0 +1,19 @@
|
|||
!tape
|
||||
name: delete_execution_success
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:45:47.749Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/execution/643
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1hlysemt7deir1j9r7l6ildg5x;Path=/
|
Loading…
Add table
Add a link
Reference in a new issue