*
* RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
* List<RundeckJob> jobs = rundeck.getJobs();
*
* RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
* RundeckExecution execution = rundeck.triggerJob(job.getId(),
* new OptionsBuilder().addOption("version", "1.2.0").toProperties());
*
* List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
*
*
*
* @author Vincent Behar
*/
public class RundeckClient implements Serializable {
private static final long serialVersionUID = 1L;
public static final transient int API_VERSION = 1;
public static final transient String API_ENDPOINT = "/api/" + API_VERSION;
private final String url;
private final String login;
private final String password;
/**
* Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url
*
* @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
* @param login
* @param password
* @throws IllegalArgumentException if the url, login or password is blank (null, empty or whitespace)
*/
public RundeckClient(String url, String login, String password) throws IllegalArgumentException {
super();
this.url = url;
this.login = login;
this.password = password;
AssertUtil.notBlank(url, "The RunDeck URL is mandatory !");
AssertUtil.notBlank(login, "The RunDeck login is mandatory !");
AssertUtil.notBlank(password, "The RunDeck password is mandatory !");
}
/**
* Try to "ping" the RunDeck instance to see if it is alive
*
* @throws RundeckApiException if the ping fails
*/
public void ping() throws RundeckApiException {
new ApiCall(this).ping();
}
/**
* Test your credentials (login/password) on the RunDeck instance
*
* @throws RundeckApiLoginException if the login fails
*/
public void testCredentials() throws RundeckApiLoginException {
new ApiCall(this).testCredentials();
}
/*
* Projects
*/
/**
* List all projects
*
* @return a {@link List} of {@link RundeckProject} : might be empty, but won't be null
* @throws RundeckApiException in case of error when calling the API
* @throws RundeckApiLoginException if the login failed
*/
public List