mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-09 22:49:08 +00:00
add an OptionsBuilder (easier to use in scripts)
This commit is contained in:
parent
3720fe9d31
commit
48948d4c52
2 changed files with 47 additions and 3 deletions
|
@ -19,6 +19,7 @@ import org.rundeck.api.parser.ProjectParser;
|
||||||
import org.rundeck.api.parser.ProjectsParser;
|
import org.rundeck.api.parser.ProjectsParser;
|
||||||
import org.rundeck.api.util.ArgsUtil;
|
import org.rundeck.api.util.ArgsUtil;
|
||||||
import org.rundeck.api.util.AssertUtil;
|
import org.rundeck.api.util.AssertUtil;
|
||||||
|
import org.rundeck.api.util.OptionsBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point to talk to a RunDeck instance
|
* Main entry point to talk to a RunDeck instance
|
||||||
|
@ -226,7 +227,7 @@ public class RundeckClient implements Serializable {
|
||||||
* end of the job execution)
|
* end of the job execution)
|
||||||
*
|
*
|
||||||
* @param jobId identifier of the job - mandatory
|
* @param jobId identifier of the job - mandatory
|
||||||
* @param options of the job - optional
|
* @param options of the job - optional. See {@link OptionsBuilder}.
|
||||||
* @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
|
* @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
|
||||||
* @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
|
* @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
|
||||||
* @throws RundeckApiLoginException if the login failed
|
* @throws RundeckApiLoginException if the login failed
|
||||||
|
@ -268,7 +269,7 @@ public class RundeckClient implements Serializable {
|
||||||
* aborted) or is still running.
|
* aborted) or is still running.
|
||||||
*
|
*
|
||||||
* @param jobId identifier of the job - mandatory
|
* @param jobId identifier of the job - mandatory
|
||||||
* @param options of the job - optional
|
* @param options of the job - optional. See {@link OptionsBuilder}.
|
||||||
* @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
|
* @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
|
||||||
* @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
|
* @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
|
||||||
* @throws RundeckApiLoginException if the login failed
|
* @throws RundeckApiLoginException if the login failed
|
||||||
|
@ -287,7 +288,7 @@ public class RundeckClient implements Serializable {
|
||||||
* know if the execution is finished (or aborted) or is still running.
|
* know if the execution is finished (or aborted) or is still running.
|
||||||
*
|
*
|
||||||
* @param jobId identifier of the job - mandatory
|
* @param jobId identifier of the job - mandatory
|
||||||
* @param options of the job - optional
|
* @param options of the job - optional. See {@link OptionsBuilder}.
|
||||||
* @param poolingInterval for checking the status of the execution. Must be > 0.
|
* @param poolingInterval for checking the status of the execution. Must be > 0.
|
||||||
* @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
|
* @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
|
||||||
* @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
|
* @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
|
||||||
|
|
43
src/main/java/org/rundeck/api/util/OptionsBuilder.java
Normal file
43
src/main/java/org/rundeck/api/util/OptionsBuilder.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package org.rundeck.api.util;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder for job options
|
||||||
|
*
|
||||||
|
* @author Vincent Behar
|
||||||
|
*/
|
||||||
|
public class OptionsBuilder {
|
||||||
|
|
||||||
|
private final Properties options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a new instance. Use {@link #addOption(Object, Object)} to add some options, and then
|
||||||
|
* {@link #toProperties()} when you're done !
|
||||||
|
*/
|
||||||
|
public OptionsBuilder() {
|
||||||
|
options = new Properties();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an option
|
||||||
|
*
|
||||||
|
* @param key of the option
|
||||||
|
* @param value of the option
|
||||||
|
* @return this, for method chaining
|
||||||
|
*/
|
||||||
|
public OptionsBuilder addOption(Object key, Object value) {
|
||||||
|
options.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a new {@link Properties} instance
|
||||||
|
*/
|
||||||
|
public Properties toProperties() {
|
||||||
|
Properties options = new Properties();
|
||||||
|
options.putAll(this.options);
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue