mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-06 13:08:38 +00:00
Add deleteProject for apiv11
This commit is contained in:
parent
f49aa63043
commit
e8672e025b
3 changed files with 67 additions and 0 deletions
|
@ -361,6 +361,23 @@ public class RundeckClient implements Serializable {
|
||||||
: "/project"
|
: "/project"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Delete a project
|
||||||
|
*
|
||||||
|
* @param projectName name of the project - mandatory
|
||||||
|
*
|
||||||
|
* @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
|
||||||
|
* @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 projectName is blank (null, empty or whitespace)
|
||||||
|
*/
|
||||||
|
public void deleteProject(String projectName) throws
|
||||||
|
RundeckApiException, RundeckApiLoginException,
|
||||||
|
RundeckApiTokenException, IllegalArgumentException {
|
||||||
|
|
||||||
|
AssertUtil.notBlank(projectName, "projectName is mandatory to create a project !");
|
||||||
|
new ApiCall(this).delete(new ApiPathBuilder("/project/", projectName));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Return the configuration of a project
|
* Return the configuration of a project
|
||||||
*
|
*
|
||||||
|
|
|
@ -90,6 +90,20 @@ public class RundeckClientTest {
|
||||||
Assert.assertEquals(null, project.getDescription());
|
Assert.assertEquals(null, project.getDescription());
|
||||||
Assert.assertNotNull(project.getProjectConfig());
|
Assert.assertNotNull(project.getProjectConfig());
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
@Betamax(tape = "delete_projectv11")
|
||||||
|
public void deleteProject() throws Exception {
|
||||||
|
RundeckClient client1 = createClient(TEST_TOKEN_6, 11);
|
||||||
|
client1.deleteProject("delete_me");
|
||||||
|
RundeckProject delete_me = null;
|
||||||
|
try {
|
||||||
|
delete_me = client1.getProject("delete_me");
|
||||||
|
Assert.fail();
|
||||||
|
} catch (RundeckApiException.RundeckApiHttpStatusException e) {
|
||||||
|
Assert.assertEquals(404,e.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
36
src/test/resources/betamax/tapes/delete_projectv11.yaml
Normal file
36
src/test/resources/betamax/tapes/delete_projectv11.yaml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
!tape
|
||||||
|
name: delete_projectv11
|
||||||
|
interactions:
|
||||||
|
- recorded: 2014-03-07T20:34:06.758Z
|
||||||
|
request:
|
||||||
|
method: DELETE
|
||||||
|
uri: http://rundeck.local:4440/api/11/project/delete_me
|
||||||
|
headers:
|
||||||
|
Host: rundeck.local:4440
|
||||||
|
Proxy-Connection: Keep-Alive
|
||||||
|
User-Agent: RunDeck API Java Client 11
|
||||||
|
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||||
|
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=17vo5m2nghd0e1dcg0hqsuxklu;Path=/
|
||||||
|
- recorded: 2014-03-07T20:34:06.903Z
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
uri: http://rundeck.local:4440/api/11/project/delete_me
|
||||||
|
headers:
|
||||||
|
Accept: text/xml
|
||||||
|
Host: rundeck.local:4440
|
||||||
|
Proxy-Connection: Keep-Alive
|
||||||
|
User-Agent: RunDeck API Java Client 11
|
||||||
|
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||||
|
response:
|
||||||
|
status: 404
|
||||||
|
headers:
|
||||||
|
Content-Type: text/xml;charset=UTF-8
|
||||||
|
Server: Jetty(7.6.0.v20120127)
|
||||||
|
X-Rundeck-API-Version: '11'
|
||||||
|
body: "<result error='true' apiversion='11'>\n <error code='api.error.item.doesnotexist'>\n <message>project does not exist: delete_me</message>\n </error>\n</result>"
|
Loading…
Add table
Add a link
Reference in a new issue