Exclude nodes matching the given hostname
@@ -242,6 +260,9 @@ Static method in class org.rundeck.api.util.generateNodeFiltersString(Properties) -
Static method in class org.rundeck.api.util.ParametersUtil
Generates an url-encoded string representing the given nodeFilters.
+
Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
@@ -989,6 +1274,9 @@ Static method in class org.rundeck.api.util.valueOf(String) -
Static method in enum org.rundeck.api.domain.RundeckAbort.AbortStatus
Returns the enum constant of this type with the specified name.
+
runAdhocScript(String project,
+ InputStream script,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
triggerAdhocScript(String project,
+ InputStream script)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ String scriptFilename)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
+
Returns:
a 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 project with this name)
+
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
options - of the script - optional. See OptionsBuilder.
+
Returns:
a 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 project with this name)
+
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
+
Returns:
a 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 project with this name)
+
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
options - of the script - optional. See OptionsBuilder.
+
Returns:
a 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 project with this name)
+
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+ script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+ RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
poolingInterval - for checking the status of the execution. Must be > 0.
poolingUnit - unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
options - of the script - optional. See OptionsBuilder.
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+ RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+ parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+ parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
scriptFilename - filename of the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+ RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
poolingInterval - for checking the status of the execution. Must be > 0.
poolingUnit - unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
options - of the script - optional. See OptionsBuilder.
+
Returns:
a RundeckExecution instance for the (finished/aborted) execution - won't be null
+
Throws:
+
RundeckApiException - in case of error when calling the API (non-existent project with this name)
+
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+ RunDeck server.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+ parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+ running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+ server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+ finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+ parameter.
+
+
+
+
+
+
Parameters:
project - name of the project - mandatory
script - inputStream for reading the script to be executed - mandatory
recent - include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+ is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+ weeks), "5d" (= last 5 days), etc. Optional.
+
recent - include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+ is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+ weeks), "5d" (= last 5 days), etc. Optional.
max - number of results to return - optional (default to 20)
offset - the 0-indexed offset for the first result to return - optional (default to O)
+
jobId - include only events matching the given job ID - optional
reportId - include only events matching the given report ID - optional
user - include only events created by the given user - optional
recent - include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+ is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+ weeks), "5d" (= last 5 days), etc. Optional.
begin - date for the earlier events to retrieve - optional
end - date for the latest events to retrieve - optional
max - number of results to return - optional (default to 20)
offset - the 0-indexed offset for the first result to return - optional (default to O)
+
RundeckClient.getHistory(String project,
+ String jobId,
+ String reportId,
+ String user,
+ Long max,
+ Long offset)
+
+
+ Get the (events) history for the given project
RundeckClient.runAdhocScript(String project,
+ InputStream script)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.triggerAdhocScript(String project,
+ InputStream script)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.getHistory(String project,
+ String jobId,
+ String reportId,
+ String user,
+ Long max,
+ Long offset)
+
+
+ Get the (events) history for the given project
RundeckClient.runAdhocScript(String project,
+ InputStream script)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.triggerAdhocScript(String project,
+ InputStream script)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
Returns an array containing the constants of this enum type, in
+the order they are declared. This method may be used to iterate
+over the constants as follows:
+
+for (RundeckEvent.EventStatus c : RundeckEvent.EventStatus.values())
+ System.out.println(c);
+
+
+
+
+
Returns:
an array containing the constants of this enum type, in
+the order they are declared
Returns the enum constant of this type with the specified name.
+The string must match exactly an identifier used to declare an
+enum constant in this type. (Extraneous whitespace characters are
+not permitted.)
+
+
+
Parameters:
name - the name of the enum constant to be returned.
+
RundeckClient.runAdhocScript(String project,
+ InputStream script)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.runAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ long poolingInterval,
+ TimeUnit poolingUnit)
+
+
+ Run an ad-hoc script, and wait until its execution is finished (or aborted) to return.
RundeckClient.triggerAdhocScript(String project,
+ InputStream script)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ InputStream script,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.triggerAdhocScript(String project,
+ String scriptFilename,
+ Properties options,
+ Properties nodeFilters,
+ Integer nodeThreadcount,
+ Boolean nodeKeepgoing)
+
+
+ Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution).
RundeckClient.getHistory(String project,
+ String jobId,
+ String reportId,
+ String user,
+ Long max,
+ Long offset)
+
+
+ Get the (events) history for the given project
public Long getDurationInMillis() {
+ if (startedAt == null || endedAt == null) {
+ return null;
+ }
+ return endedAt.getTime() - startedAt.getTime();
+ }
+
+ /**
+ * @return the duration of the execution in seconds (or null if the execution is still running, or has been aborted)
+ */
+ public Long getDurationInSeconds() {
+ Long durationInMillis = getDurationInMillis();
+ return durationInMillis != null ? TimeUnit.MILLISECONDS.toSeconds(durationInMillis) : null;
+ }
+
+ /**
+ * @return the duration of the execution, as a human-readable string : "3 minutes 34 seconds" (or null if the
+ * execution is still running, or has been aborted)
+ */
+ public String getDuration() {
+ Long durationInMillis = getDurationInMillis();
+ return durationInMillis != null ? DurationFormatUtils.formatDurationWords(durationInMillis, true, true) : null;
+ }
+
+ /**
+ * @return the duration of the execution, as a "short" human-readable string : "0:03:34.187" (or null if the
+ * execution is still running, or has been aborted)
+ */
+ public String getShortDuration() {
+ Long durationInMillis = getDurationInMillis();
+ return durationInMillis != null ? DurationFormatUtils.formatDurationHMS(durationInMillis) : null;
+ }
+
+ public Long getId() {
Description: The codec package contains simple encoder and decoders for
various formats such as Base64 and Hexadecimal. In addition to these
widely used encoders and decoders, the codec package also maintains a
- collection of phonetic encoding utilities.
Description: Commons Lang, a package of Java utility classes for the
classes that are in java.lang's hierarchy, or are considered to be so
- standard as to justify existence in java.lang.
Project License: No project license is defined for this project.
xml-apis:xml-apis:jar:1.0.b2 (compile)
XML Commons External Components XML APIs
Description: xml-commons provides an Apache-hosted set of DOM, SAX, and
JAXP interfaces for use in other xml-based projects. Our hope is that we
can standardize on both a common version and packaging scheme for these
critical XML standards interfaces to make the lives of both our developers
and users easier. The External Components portion of xml-commons contains
interfaces that are defined by external standards organizations. For DOM,
that's the W3C; for SAX it's David Megginson and sax.sourceforge.net; for
- JAXP it's Sun.
Description: There is currently no description associated with this project.
Project License: No project license is defined for this project.
xerces:xercesImpl:jar:2.6.2 (compile)
Unnamed - xerces:xercesImpl:jar:2.6.2
Description: There is currently no description associated with this project.
Project License: No project license is defined for this project.
xalan:xalan:jar:2.6.0 (compile)
Unnamed - xalan:xalan:jar:2.6.0
Description: There is currently no description associated with this project.
Project License: No project license is defined for this project.
xml-apis:xml-apis:jar:1.0.b2 (compile)
XML Commons External Components XML APIs
Description: xml-commons provides an Apache-hosted set of DOM, SAX, and
JAXP interfaces for use in other xml-based projects. Our hope is that we
can standardize on both a common version and packaging scheme for these
critical XML standards interfaces to make the lives of both our developers
and users easier. The External Components portion of xml-commons contains
interfaces that are defined by external standards organizations. For DOM,
that's the W3C; for SAX it's David Megginson and sax.sourceforge.net; for
- JAXP it's Sun.
The Apache Software License, Version 2.0: Commons Codec, Commons IO, Commons Lang, Commons Logging, RunDeck API - Java Client, XML Commons External Components XML APIs
The Apache Software License, Version 2.0: Commons Codec, Commons IO, Commons Lang, Commons Logging, RunDeck API - Java Client, XML Commons External Components XML APIs
Here are some examples of what you can do with this lib and a few lines of Groovy.
We can use Grape to download the lib (and its dependencies) from the Maven Central Repository, so you don't have to install anything manually (except Groovy, of course).
Basic usage
Save the following script in a file named "rundeck.groovy", and execute it with "groovy rundeck.groovy". Feeling Groovy ? ;-)
// we use Grape (Ivy) to download the lib (and its dependencies) from Maven Central Repository
-@Grab(group='org.rundeck', module='rundeck-api-java-client', version='1.1')
+@Grab(group='org.rundeck', module='rundeck-api-java-client', version='1.2')
import org.rundeck.api.RundeckClient
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
@@ -159,6 +162,14 @@ execution = rundeck.triggerAdhocCommand("my-project", "uptime&quo
// run the "uptime" command on all unix nodes
execution = rundeck.runAdhocCommand("my-project", "uptime", new Properties(os-family: "unix"))
+
Running an ad-hoc script
import org.rundeck.api.RundeckClient
+rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
+
+// trigger the execution of a custom bash script on the RunDeck server
+execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
+
+// run a bash script (with options) on all unix nodes
+execution = rundeck.runAdhocCommand("my-project", "/tmp/my-script-with-options.sh", new Properties(option1: "value one"), new Properties(os-family: "unix"))
API Documentation
@@ -164,6 +167,17 @@ execution = rundeck.triggerAdhocCommand("my-project", "uptime&quo
// run the "uptime" command on all unix nodes
execution = rundeck.runAdhocCommand("my-project", "uptime", NodeFiltersBuilder.new().osFamily("unix").toProperties())
+
Running an ad-hoc script
import org.rundeck.api.RundeckClient
+import org.rundeck.api.OptionsBuilder
+import org.rundeck.api.NodeFiltersBuilder
+
+rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
+
+// trigger the execution of a custom bash script on the RunDeck server
+execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
+
+// run a bash script (with options) on all unix nodes
+execution = rundeck.runAdhocCommand("my-project", "/tmp/my-script-with-options.sh", OptionsBuilder.new().addOption("option1", "value one").toProperties(), NodeFiltersBuilder.new().osFamily("unix").toProperties())
API Documentation
@@ -153,6 +156,17 @@ execution = rundeck.triggerAdhocCommand("my-project", "uptime&quo
// run the "uptime" command on all unix nodes
execution = rundeck.runAdhocCommand("my-project", "uptime", NodeFiltersBuilder().osFamily("unix").toProperties())
+
Running an ad-hoc script
from org.rundeck.api import RundeckClient
+from org.rundeck.api import OptionsBuilder
+from org.rundeck.api import NodeFiltersBuilder
+
+rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
+
+// trigger the execution of a custom bash script on the RunDeck server
+execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
+
+// run a bash script (with options) on all unix nodes
+execution = rundeck.runAdhocCommand("my-project", "/tmp/my-script-with-options.sh", OptionsBuilder().addOption("option1", "value one").toProperties(), NodeFiltersBuilder().osFamily("unix").toProperties())
@@ -221,7 +241,7 @@ Constructor for class org.rundeck.api.parser.AEGJLNOPS
+AEGHJLNOPS
diff --git a/testapidocs/index.html b/testapidocs/index.html
index 2c8267d..520fd35 100644
--- a/testapidocs/index.html
+++ b/testapidocs/index.html
@@ -2,10 +2,10 @@
-
+
-RunDeck API - Java Client 1.1 Test API
+RunDeck API - Java Client 1.2 Test API
@@ -57,7 +57,7 @@ function windowTitle()
RundeckJob
diff --git a/xref/index.html b/xref/index.html
index a8de5d6..fdd3988 100644
--- a/xref/index.html
+++ b/xref/index.html
@@ -3,7 +3,7 @@
- RunDeck API - Java Client 1.1 Reference
+ RunDeck API - Java Client 1.2 Reference
diff --git a/xref/org/rundeck/api/ApiPathBuilder.html b/xref/org/rundeck/api/ApiPathBuilder.html
index 5fcdb12..fe3ab3d 100644
--- a/xref/org/rundeck/api/ApiPathBuilder.html
+++ b/xref/org/rundeck/api/ApiPathBuilder.html
@@ -26,191 +26,207 @@
16package org.rundeck.api;
1718import java.io.InputStream;
-19import java.util.HashMap;
-20import java.util.Map;
-21import java.util.Properties;
-22import org.apache.commons.lang.StringUtils;
-23import org.rundeck.api.util.ParametersUtil;
-24
-25/**
-26 * Builder for API paths
-27 *
-28 * @author Vincent Behar
-29 */
-30classApiPathBuilder {
-31
-32/** Internally, we store everything in a {@link StringBuilder} */
-33privatefinal StringBuilder apiPath;
-34
-35/** When POSTing, we can add attachments */
-36privatefinal Map<String, InputStream> attachments;
-37
-38/** Marker for using the right separator between parameters ("?" or "&") */
-39privateboolean firstParamDone = false;
-40
-41/**
-42 * Build a new instance, for the given "path" (the "path" is the part before the parameters. The path and the
-43 * parameters are separated by a "?")
-44 *
-45 * @param paths elements of the path
-46 */
-47publicApiPathBuilder(String... paths) {
-48 apiPath = new StringBuilder();
-49 attachments = new HashMap<String, InputStream>();
-50if (paths != null) {
-51for (String path : paths) {
-52if (StringUtils.isNotBlank(path)) {
-53 append(path);
-54 }
-55 }
-56 }
-57 }
-58
-59/**
-60 * Append the given parameter (key and value). This will only append the parameter if it is not blank (null, empty
-61 * or whitespace), and make sure to add the right separator ("?" or "&") before. The key and value will be separated
-62 * by the "=" character. Also, the value will be url-encoded.
-63 *
-64 * @param key of the parameter. Must not be null or empty
-65 * @param value of the parameter. May be null/empty/blank. Will be url-encoded.
-66 * @return this, for method chaining
-67 */
-68publicApiPathBuilder param(String key, String value) {
-69if (StringUtils.isNotBlank(value)) {
-70 appendSeparator();
-71 append(key);
-72 append("=");
-73 append(ParametersUtil.urlEncode(value));
-74 }
-75returnthis;
-76 }
-77
-78/**
-79 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
-80 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character. Also,
-81 * the value will be converted to lower-case.
-82 *
-83 * @param key of the parameter. Must not be null or empty
-84 * @param value of the parameter. May be null
-85 * @return this, for method chaining
-86 */
-87publicApiPathBuilder param(String key, Enum<?> value) {
-88if (value != null) {
-89 param(key, StringUtils.lowerCase(value.toString()));
-90 }
-91returnthis;
-92 }
-93
-94/**
-95 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
-96 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
-97 *
-98 * @param key of the parameter. Must not be null or empty
-99 * @param value of the parameter. May be null
-100 * @return this, for method chaining
-101 */
-102publicApiPathBuilder param(String key, Long value) {
-103if (value != null) {
-104 param(key, value.toString());
-105 }
-106returnthis;
-107 }
-108
-109/**
-110 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
-111 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
-112 *
-113 * @param key of the parameter. Must not be null or empty
-114 * @param value of the parameter. May be null
-115 * @return this, for method chaining
-116 */
-117publicApiPathBuilder param(String key, Integer value) {
-118if (value != null) {
-119 param(key, value.toString());
-120 }
-121returnthis;
-122 }
-123
-124/**
-125 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
-126 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
-127 *
-128 * @param key of the parameter. Must not be null or empty
-129 * @param value of the parameter. May be null
-130 * @return this, for method chaining
-131 */
-132publicApiPathBuilder param(String key, Boolean value) {
-133if (value != null) {
-134 param(key, value.toString());
-135 }
-136returnthis;
-137 }
-138
-139/**
-140 * Append the given node filters, only if it is not null/empty
-141 *
-142 * @param nodeFilters may be null/empty
-143 * @return this, for method chaining
-144 * @see ParametersUtil#generateNodeFiltersString(Properties)
-145 */
-146publicApiPathBuilder nodeFilters(Properties nodeFilters) {
-147 String filters = ParametersUtil.generateNodeFiltersString(nodeFilters);
-148if (StringUtils.isNotBlank(filters)) {
-149 appendSeparator();
-150 append(filters);
+19import java.util.Date;
+20import java.util.HashMap;
+21import java.util.Map;
+22import java.util.Properties;
+23import org.apache.commons.lang.StringUtils;
+24import org.rundeck.api.util.ParametersUtil;
+25
+26/**
+27 * Builder for API paths
+28 *
+29 * @author Vincent Behar
+30 */
+31classApiPathBuilder {
+32
+33/** Internally, we store everything in a {@link StringBuilder} */
+34privatefinal StringBuilder apiPath;
+35
+36/** When POSTing, we can add attachments */
+37privatefinal Map<String, InputStream> attachments;
+38
+39/** Marker for using the right separator between parameters ("?" or "&") */
+40privateboolean firstParamDone = false;
+41
+42/**
+43 * Build a new instance, for the given "path" (the "path" is the part before the parameters. The path and the
+44 * parameters are separated by a "?")
+45 *
+46 * @param paths elements of the path
+47 */
+48publicApiPathBuilder(String... paths) {
+49 apiPath = new StringBuilder();
+50 attachments = new HashMap<String, InputStream>();
+51if (paths != null) {
+52for (String path : paths) {
+53if (StringUtils.isNotBlank(path)) {
+54 append(path);
+55 }
+56 }
+57 }
+58 }
+59
+60/**
+61 * Append the given parameter (key and value). This will only append the parameter if it is not blank (null, empty
+62 * or whitespace), and make sure to add the right separator ("?" or "&") before. The key and value will be separated
+63 * by the "=" character. Also, the value will be url-encoded.
+64 *
+65 * @param key of the parameter. Must not be null or empty
+66 * @param value of the parameter. May be null/empty/blank. Will be url-encoded.
+67 * @return this, for method chaining
+68 */
+69publicApiPathBuilder param(String key, String value) {
+70if (StringUtils.isNotBlank(value)) {
+71 appendSeparator();
+72 append(key);
+73 append("=");
+74 append(ParametersUtil.urlEncode(value));
+75 }
+76returnthis;
+77 }
+78
+79/**
+80 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
+81 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character. Also,
+82 * the value will be converted to lower-case.
+83 *
+84 * @param key of the parameter. Must not be null or empty
+85 * @param value of the parameter. May be null
+86 * @return this, for method chaining
+87 */
+88publicApiPathBuilder param(String key, Enum<?> value) {
+89if (value != null) {
+90 param(key, StringUtils.lowerCase(value.toString()));
+91 }
+92returnthis;
+93 }
+94
+95/**
+96 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
+97 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
+98 *
+99 * @param key of the parameter. Must not be null or empty
+100 * @param value of the parameter. May be null
+101 * @return this, for method chaining
+102 */
+103publicApiPathBuilder param(String key, Date value) {
+104if (value != null) {
+105 param(key, value.getTime());
+106 }
+107returnthis;
+108 }
+109
+110/**
+111 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
+112 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
+113 *
+114 * @param key of the parameter. Must not be null or empty
+115 * @param value of the parameter. May be null
+116 * @return this, for method chaining
+117 */
+118publicApiPathBuilder param(String key, Long value) {
+119if (value != null) {
+120 param(key, value.toString());
+121 }
+122returnthis;
+123 }
+124
+125/**
+126 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
+127 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
+128 *
+129 * @param key of the parameter. Must not be null or empty
+130 * @param value of the parameter. May be null
+131 * @return this, for method chaining
+132 */
+133publicApiPathBuilder param(String key, Integer value) {
+134if (value != null) {
+135 param(key, value.toString());
+136 }
+137returnthis;
+138 }
+139
+140/**
+141 * Append the given parameter (key and value). This will only append the parameter if it is not null, and make sure
+142 * to add the right separator ("?" or "&") before. The key and value will be separated by the "=" character.
+143 *
+144 * @param key of the parameter. Must not be null or empty
+145 * @param value of the parameter. May be null
+146 * @return this, for method chaining
+147 */
+148publicApiPathBuilder param(String key, Boolean value) {
+149if (value != null) {
+150 param(key, value.toString());
151 }
152returnthis;
153 }
154155/**
-156 * When POSTing a request, add the given {@link InputStream} as an attachment to the content of the request. This
-157 * will only add the stream if it is not null.
-158 *
-159 * @param name of the attachment. Must not be null or empty
-160 * @param stream. May be null
-161 * @return this, for method chaining
-162 */
-163publicApiPathBuilder attach(String name, InputStream stream) {
-164if (stream != null) {
-165 attachments.put(name, stream);
-166 }
-167returnthis;
-168 }
-169
-170/**
-171 * @return all attachments to be POSTed, with their names
-172 */
-173public Map<String, InputStream> getAttachments() {
-174return attachments;
-175 }
-176
-177 @Override
-178public String toString() {
-179return apiPath.toString();
-180 }
-181
-182/**
-183 * Append the given string
-184 *
-185 * @param str to append
-186 */
-187privatevoid append(String str) {
-188 apiPath.append(str);
-189 }
-190
-191/**
-192 * Append the right separator "?" or "&" between 2 parameters
-193 */
-194privatevoid appendSeparator() {
-195if (firstParamDone) {
-196 append("&");
-197 } else {
-198 append("?");
-199 firstParamDone = true;
-200 }
-201 }
-202
-203 }
+156 * Append the given node filters, only if it is not null/empty
+157 *
+158 * @param nodeFilters may be null/empty
+159 * @return this, for method chaining
+160 * @see ParametersUtil#generateNodeFiltersString(Properties)
+161 */
+162publicApiPathBuilder nodeFilters(Properties nodeFilters) {
+163 String filters = ParametersUtil.generateNodeFiltersString(nodeFilters);
+164if (StringUtils.isNotBlank(filters)) {
+165 appendSeparator();
+166 append(filters);
+167 }
+168returnthis;
+169 }
+170
+171/**
+172 * When POSTing a request, add the given {@link InputStream} as an attachment to the content of the request. This
+173 * will only add the stream if it is not null.
+174 *
+175 * @param name of the attachment. Must not be null or empty
+176 * @param stream. May be null
+177 * @return this, for method chaining
+178 */
+179publicApiPathBuilder attach(String name, InputStream stream) {
+180if (stream != null) {
+181 attachments.put(name, stream);
+182 }
+183returnthis;
+184 }
+185
+186/**
+187 * @return all attachments to be POSTed, with their names
+188 */
+189public Map<String, InputStream> getAttachments() {
+190return attachments;
+191 }
+192
+193 @Override
+194public String toString() {
+195return apiPath.toString();
+196 }
+197
+198/**
+199 * Append the given string
+200 *
+201 * @param str to append
+202 */
+203privatevoid append(String str) {
+204 apiPath.append(str);
+205 }
+206
+207/**
+208 * Append the right separator "?" or "&" between 2 parameters
+209 */
+210privatevoid appendSeparator() {
+211if (firstParamDone) {
+212 append("&");
+213 } else {
+214 append("?");
+215 firstParamDone = true;
+216 }
+217 }
+218
+219 }
diff --git a/xref/org/rundeck/api/RundeckClient.html b/xref/org/rundeck/api/RundeckClient.html
index a0369a3..eee41de 100644
--- a/xref/org/rundeck/api/RundeckClient.html
+++ b/xref/org/rundeck/api/RundeckClient.html
@@ -31,1378 +31,2215 @@
21import java.io.InputStream;
22import java.io.Serializable;
23import java.util.ArrayList;
-24import java.util.List;
-25import java.util.Properties;
-26import java.util.concurrent.TimeUnit;
-27import org.apache.commons.io.FileUtils;
-28import org.apache.commons.io.IOUtils;
-29import org.apache.commons.lang.StringUtils;
-30import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
-31import org.rundeck.api.domain.RundeckAbort;
-32import org.rundeck.api.domain.RundeckExecution;
-33import org.rundeck.api.domain.RundeckJob;
-34import org.rundeck.api.domain.RundeckJobsImportMethod;
-35import org.rundeck.api.domain.RundeckJobsImportResult;
-36import org.rundeck.api.domain.RundeckNode;
-37import org.rundeck.api.domain.RundeckProject;
-38import org.rundeck.api.domain.RundeckSystemInfo;
-39import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
-40import org.rundeck.api.parser.AbortParser;
-41import org.rundeck.api.parser.ExecutionParser;
-42import org.rundeck.api.parser.JobParser;
-43import org.rundeck.api.parser.JobsImportResultParser;
-44import org.rundeck.api.parser.ListParser;
-45import org.rundeck.api.parser.NodeParser;
-46import org.rundeck.api.parser.ProjectParser;
-47import org.rundeck.api.parser.StringParser;
-48import org.rundeck.api.parser.SystemInfoParser;
-49import org.rundeck.api.util.AssertUtil;
-50import org.rundeck.api.util.ParametersUtil;
-51
-52/**
-53 * Main entry point to talk to a RunDeck instance.<br>
-54 * Usage : <br>
-55 * <code>
-56 * <pre>
-57 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
-58 *
-59 * List<RundeckProject> projects = rundeck.getProjects();
-60 *
-61 * RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
-62 * RundeckExecution execution = rundeck.triggerJob(job.getId(),
-63 * new OptionsBuilder().addOption("version", "1.2.0").toProperties());
-64 *
-65 * List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
-66 *
-67 * rundeck.exportJobsToFile("/tmp/jobs.xml", FileType.XML, "my-project");
-68 * rundeck.importJobs("/tmp/jobs.xml", FileType.XML);
-69 * </pre>
-70 * </code>
-71 *
-72 * @author Vincent Behar
-73 */
-74publicclassRundeckClientimplements Serializable {
-75
-76privatestaticfinallong serialVersionUID = 1L;
-77
-78publicstaticfinaltransientint API_VERSION = 1;
-79
-80publicstaticfinaltransient String API_ENDPOINT = "/api/" + API_VERSION;
-81
-82privatefinal String url;
+24import java.util.Date;
+25import java.util.List;
+26import java.util.Properties;
+27import java.util.concurrent.TimeUnit;
+28import org.apache.commons.io.FileUtils;
+29import org.apache.commons.io.IOUtils;
+30import org.apache.commons.lang.StringUtils;
+31import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
+32import org.rundeck.api.domain.RundeckAbort;
+33import org.rundeck.api.domain.RundeckExecution;
+34import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
+35import org.rundeck.api.domain.RundeckHistory;
+36import org.rundeck.api.domain.RundeckJob;
+37import org.rundeck.api.domain.RundeckJobsImportMethod;
+38import org.rundeck.api.domain.RundeckJobsImportResult;
+39import org.rundeck.api.domain.RundeckNode;
+40import org.rundeck.api.domain.RundeckProject;
+41import org.rundeck.api.domain.RundeckSystemInfo;
+42import org.rundeck.api.parser.AbortParser;
+43import org.rundeck.api.parser.ExecutionParser;
+44import org.rundeck.api.parser.HistoryParser;
+45import org.rundeck.api.parser.JobParser;
+46import org.rundeck.api.parser.JobsImportResultParser;
+47import org.rundeck.api.parser.ListParser;
+48import org.rundeck.api.parser.NodeParser;
+49import org.rundeck.api.parser.ProjectParser;
+50import org.rundeck.api.parser.StringParser;
+51import org.rundeck.api.parser.SystemInfoParser;
+52import org.rundeck.api.util.AssertUtil;
+53import org.rundeck.api.util.ParametersUtil;
+54
+55/**
+56 * Main entry point to talk to a RunDeck instance.<br>
+57 * Usage : <br>
+58 * <code>
+59 * <pre>
+60 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
+61 *
+62 * List<RundeckProject> projects = rundeck.getProjects();
+63 *
+64 * RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
+65 * RundeckExecution execution = rundeck.triggerJob(job.getId(),
+66 * new OptionsBuilder().addOption("version", "1.2.0").toProperties());
+67 *
+68 * List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
+69 *
+70 * rundeck.exportJobsToFile("/tmp/jobs.xml", FileType.XML, "my-project");
+71 * rundeck.importJobs("/tmp/jobs.xml", FileType.XML);
+72 * </pre>
+73 * </code>
+74 *
+75 * @author Vincent Behar
+76 */
+77publicclassRundeckClientimplements Serializable {
+78
+79privatestaticfinallong serialVersionUID = 1L;
+80
+81/** Version of the API supported */
+82publicstaticfinaltransientint API_VERSION = 1;
83
-84privatefinal String login;
-85
-86privatefinal String password;
-87
-88/**
-89 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url
-90 *
-91 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
-92 * @param login
-93 * @param password
-94 * @throws IllegalArgumentException if the url, login or password is blank (null, empty or whitespace)
-95 */
-96publicRundeckClient(String url, String login, String password) throws IllegalArgumentException {
-97super();
-98this.url = url;
-99this.login = login;
-100this.password = password;
-101 AssertUtil.notBlank(url, "The RunDeck URL is mandatory !");
-102 AssertUtil.notBlank(login, "The RunDeck login is mandatory !");
-103 AssertUtil.notBlank(password, "The RunDeck password is mandatory !");
-104 }
-105
-106/**
-107 * Try to "ping" the RunDeck instance to see if it is alive
-108 *
-109 * @throws RundeckApiException if the ping fails
-110 */
-111publicvoid ping() throws RundeckApiException {
-112newApiCall(this).ping();
-113 }
-114
-115/**
-116 * Test your credentials (login/password) on the RunDeck instance
-117 *
-118 * @throws RundeckApiLoginException if the login fails
-119 */
-120publicvoid testCredentials() throws RundeckApiLoginException {
-121newApiCall(this).testCredentials();
-122 }
-123
-124/*
-125 * Projects
-126 */
-127
-128/**
-129 * List all projects
-130 *
-131 * @return a {@link List} of {@link RundeckProject} : might be empty, but won't be null
-132 * @throws RundeckApiException in case of error when calling the API
-133 * @throws RundeckApiLoginException if the login failed
-134 */
-135public List<RundeckProject> getProjects() throws RundeckApiException, RundeckApiLoginException {
-136returnnewApiCall(this).get(newApiPathBuilder("/projects"),
-137new ListParser<RundeckProject>(newProjectParser(), "result/projects/project"));
-138 }
-139
-140/**
-141 * Get the definition of a single project, identified by the given name
-142 *
-143 * @param projectName name of the project - mandatory
-144 * @return a {@link RundeckProject} instance - won't be null
-145 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-146 * @throws RundeckApiLoginException if the login failed
-147 * @throws IllegalArgumentException if the projectName is blank (null, empty or whitespace)
+84/** End-point of the API */
+85publicstaticfinaltransient String API_ENDPOINT = "/api/" + API_VERSION;
+86
+87/** Default value for the "pooling interval" used when running jobs/commands/scripts */
+88privatestaticfinaltransientlong DEFAULT_POOLING_INTERVAL = 5;
+89
+90/** Default unit of the "pooling interval" used when running jobs/commands/scripts */
+91privatestaticfinaltransient TimeUnit DEFAULT_POOLING_UNIT = TimeUnit.SECONDS;
+92
+93/** URL of the RunDeck instance ("http://localhost:4440" target="alexandria_uri">http://localhost:4440", "http://rundeck.your-compagny.com/", etc) */
+94privatefinal String url;
+95
+96/** Login to use for authentication on the RunDeck instance */
+97privatefinal String login;
+98
+99/** Password to use for authentication on the RunDeck instance */
+100privatefinal String password;
+101
+102/**
+103 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url
+104 *
+105 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
+106 * @param login
+107 * @param password
+108 * @throws IllegalArgumentException if the url, login or password is blank (null, empty or whitespace)
+109 */
+110publicRundeckClient(String url, String login, String password) throws IllegalArgumentException {
+111super();
+112this.url = url;
+113this.login = login;
+114this.password = password;
+115 AssertUtil.notBlank(url, "The RunDeck URL is mandatory !");
+116 AssertUtil.notBlank(login, "The RunDeck login is mandatory !");
+117 AssertUtil.notBlank(password, "The RunDeck password is mandatory !");
+118 }
+119
+120/**
+121 * Try to "ping" the RunDeck instance to see if it is alive
+122 *
+123 * @throws RundeckApiException if the ping fails
+124 */
+125publicvoid ping() throws RundeckApiException {
+126newApiCall(this).ping();
+127 }
+128
+129/**
+130 * Test your credentials (login/password) on the RunDeck instance
+131 *
+132 * @throws RundeckApiLoginException if the login fails
+133 */
+134publicvoid testCredentials() throws RundeckApiLoginException {
+135newApiCall(this).testCredentials();
+136 }
+137
+138/*
+139 * Projects
+140 */
+141
+142/**
+143 * List all projects
+144 *
+145 * @return a {@link List} of {@link RundeckProject} : might be empty, but won't be null
+146 * @throws RundeckApiException in case of error when calling the API
+147 * @throws RundeckApiLoginException if the login failed148 */
-149publicRundeckProject getProject(String projectName) throws RundeckApiException, RundeckApiLoginException,
-150 IllegalArgumentException {
-151 AssertUtil.notBlank(projectName, "projectName is mandatory to get the details of a project !");
-152returnnewApiCall(this).get(newApiPathBuilder("/project/", projectName),
-153newProjectParser("result/projects/project"));
-154 }
-155
-156/*
-157 * Jobs
-158 */
-159
-160/**
-161 * List all jobs (for all projects)
-162 *
-163 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
-164 * @throws RundeckApiException in case of error when calling the API
-165 * @throws RundeckApiLoginException if the login failed
-166 */
-167public List<RundeckJob> getJobs() throws RundeckApiException, RundeckApiLoginException {
-168 List<RundeckJob> jobs = new ArrayList<RundeckJob>();
-169for (RundeckProject project : getProjects()) {
-170 jobs.addAll(getJobs(project.getName()));
-171 }
-172return jobs;
-173 }
-174
-175/**
-176 * List all jobs that belongs to the given project
-177 *
-178 * @param project name of the project - mandatory
-179 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
-180 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-181 * @throws RundeckApiLoginException if the login failed
-182 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-183 * @see #getJobs(String, String, String, String...)
-184 */
-185public List<RundeckJob> getJobs(String project) throws RundeckApiException, RundeckApiLoginException,
-186 IllegalArgumentException {
-187return getJobs(project, null, null, new String[0]);
-188 }
-189
-190/**
-191 * List the jobs that belongs to the given project, and matches the given criteria (jobFilter, groupPath and jobIds)
-192 *
-193 * @param project name of the project - mandatory
-194 * @param jobFilter a filter for the job Name - optional
-195 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-196 * @param jobIds a list of Job IDs to include - optional
-197 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
-198 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-199 * @throws RundeckApiLoginException if the login failed
-200 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-201 * @see #getJobs(String)
-202 */
-203public List<RundeckJob> getJobs(String project, String jobFilter, String groupPath, String... jobIds)
-204throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-205 AssertUtil.notBlank(project, "project is mandatory to get all jobs !");
-206returnnewApiCall(this).get(newApiPathBuilder("/jobs").param("project", project)
-207 .param("jobFilter", jobFilter)
-208 .param("groupPath", groupPath)
-209 .param("idlist", StringUtils.join(jobIds, ",")),
-210new ListParser<RundeckJob>(newJobParser(), "result/jobs/job"));
-211 }
-212
-213/**
-214 * Export the definitions of all jobs that belongs to the given project
-215 *
-216 * @param filename path of the file where the content should be saved - mandatory
-217 * @param format of the export. See {@link FileType} - mandatory
-218 * @param project name of the project - mandatory
-219 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-220 * @throws RundeckApiLoginException if the login failed
-221 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-222 * invalid
-223 * @throws IOException if we failed to write to the file
-224 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-225 * @see #exportJobs(String, String)
-226 */
-227publicvoid exportJobsToFile(String filename, String format, String project) throws RundeckApiException,
-228 RundeckApiLoginException, IllegalArgumentException, IOException {
-229 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-230 exportJobsToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), project);
-231 }
-232
-233/**
-234 * Export the definitions of all jobs that belongs to the given project
-235 *
-236 * @param filename path of the file where the content should be saved - mandatory
-237 * @param format of the export. See {@link FileType} - mandatory
-238 * @param project name of the project - mandatory
-239 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-240 * @throws RundeckApiLoginException if the login failed
-241 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-242 * @throws IOException if we failed to write to the file
-243 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-244 * @see #exportJobs(FileType, String)
-245 */
-246publicvoid exportJobsToFile(String filename, FileType format, String project) throws RundeckApiException,
-247 RundeckApiLoginException, IllegalArgumentException, IOException {
-248 exportJobsToFile(filename, format, project, null, null, new String[0]);
-249 }
-250
-251/**
-252 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-253 * groupPath and jobIds)
-254 *
-255 * @param filename path of the file where the content should be saved - mandatory
-256 * @param format of the export. See {@link FileType} - mandatory
-257 * @param project name of the project - mandatory
-258 * @param jobFilter a filter for the job Name - optional
-259 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-260 * @param jobIds a list of Job IDs to include - optional
-261 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-262 * @throws RundeckApiLoginException if the login failed
-263 * @throws IllegalArgumentException if the filename, format or project is blank (null, empty or whitespace), or the
-264 * format is invalid
-265 * @throws IOException if we failed to write to the file
-266 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-267 * @see #exportJobs(FileType, String, String, String, String...)
-268 */
-269publicvoid exportJobsToFile(String filename, String format, String project, String jobFilter, String groupPath,
-270 String... jobIds) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
-271 IOException {
-272 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-273 exportJobsToFile(filename,
-274 FileType.valueOf(StringUtils.upperCase(format)),
-275 project,
-276 jobFilter,
-277 groupPath,
-278 jobIds);
-279 }
-280
-281/**
-282 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-283 * groupPath and jobIds)
-284 *
-285 * @param filename path of the file where the content should be saved - mandatory
-286 * @param format of the export. See {@link FileType} - mandatory
-287 * @param project name of the project - mandatory
-288 * @param jobFilter a filter for the job Name - optional
-289 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-290 * @param jobIds a list of Job IDs to include - optional
-291 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-292 * @throws RundeckApiLoginException if the login failed
-293 * @throws IllegalArgumentException if the filename or project is blank (null, empty or whitespace), or the format
-294 * is null
-295 * @throws IOException if we failed to write to the file
-296 * @see #exportJobs(FileType, String, String, String, String...)
-297 */
-298publicvoid exportJobsToFile(String filename, FileType format, String project, String jobFilter, String groupPath,
-299 String... jobIds) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
-300 IOException {
-301 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
-302 InputStream inputStream = exportJobs(format, project, jobFilter, groupPath, jobIds);
-303 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
-304 }
-305
-306/**
-307 * Export the definitions of all jobs that belongs to the given project
-308 *
-309 * @param format of the export. See {@link FileType} - mandatory
-310 * @param project name of the project - mandatory
-311 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-312 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-313 * @throws RundeckApiLoginException if the login failed
-314 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-315 * invalid
-316 * @see #exportJobs(FileType, String, String, String, String...)
-317 * @see #exportJobsToFile(String, String, String)
-318 */
-319public InputStream exportJobs(String format, String project) throws RundeckApiException, RundeckApiLoginException,
-320 IllegalArgumentException {
-321 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-322return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project);
-323 }
-324
-325/**
-326 * Export the definitions of all jobs that belongs to the given project
-327 *
-328 * @param format of the export. See {@link FileType} - mandatory
-329 * @param project name of the project - mandatory
-330 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-331 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-332 * @throws RundeckApiLoginException if the login failed
-333 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-334 * @see #exportJobs(FileType, String, String, String, String...)
-335 * @see #exportJobsToFile(String, FileType, String)
-336 */
-337public InputStream exportJobs(FileType format, String project) throws RundeckApiException,
-338 RundeckApiLoginException, IllegalArgumentException {
-339return exportJobs(format, project, null, null, new String[0]);
-340 }
-341
-342/**
-343 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-344 * groupPath and jobIds)
-345 *
-346 * @param format of the export. See {@link FileType} - mandatory
-347 * @param project name of the project - mandatory
-348 * @param jobFilter a filter for the job Name - optional
-349 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-350 * @param jobIds a list of Job IDs to include - optional
-351 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-352 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-353 * @throws RundeckApiLoginException if the login failed
-354 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-355 * invalid
-356 * @see #exportJobs(FileType, String, String, String, String...)
-357 * @see #exportJobsToFile(String, String, String, String, String, String...)
-358 */
-359public InputStream exportJobs(String format, String project, String jobFilter, String groupPath, String... jobIds)
-360throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-361 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-362return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project, jobFilter, groupPath, jobIds);
-363 }
-364
-365/**
-366 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-367 * groupPath and jobIds)
-368 *
-369 * @param format of the export. See {@link FileType} - mandatory
-370 * @param project name of the project - mandatory
-371 * @param jobFilter a filter for the job Name - optional
-372 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-373 * @param jobIds a list of Job IDs to include - optional
-374 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-375 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-376 * @throws RundeckApiLoginException if the login failed
-377 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-378 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-379 */
-380public InputStream exportJobs(FileType format, String project, String jobFilter, String groupPath, String... jobIds)
-381throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-382 AssertUtil.notNull(format, "format is mandatory to export jobs !");
-383 AssertUtil.notBlank(project, "project is mandatory to export jobs !");
-384returnnewApiCall(this).get(newApiPathBuilder("/jobs/export").param("format", format)
-385 .param("project", project)
-386 .param("jobFilter", jobFilter)
-387 .param("groupPath", groupPath)
-388 .param("idlist", StringUtils.join(jobIds, ",")));
-389 }
-390
-391/**
-392 * Export the definition of a single job (identified by the given ID)
-393 *
-394 * @param filename path of the file where the content should be saved - mandatory
-395 * @param format of the export. See {@link FileType} - mandatory
-396 * @param jobId identifier of the job - mandatory
-397 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-398 * @throws RundeckApiLoginException if the login failed
-399 * @throws IllegalArgumentException if the filename, format or jobId is blank (null, empty or whitespace), or the
-400 * format is invalid
-401 * @throws IOException if we failed to write to the file
-402 * @see #exportJobToFile(String, FileType, String)
-403 * @see #exportJob(String, String)
-404 * @see #getJob(String)
-405 */
-406publicvoid exportJobToFile(String filename, String format, String jobId) throws RundeckApiException,
-407 RundeckApiLoginException, IllegalArgumentException, IOException {
-408 AssertUtil.notBlank(format, "format is mandatory to export a job !");
-409 exportJobToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), jobId);
-410 }
-411
-412/**
-413 * Export the definition of a single job (identified by the given ID)
-414 *
-415 * @param filename path of the file where the content should be saved - mandatory
-416 * @param format of the export. See {@link FileType} - mandatory
-417 * @param jobId identifier of the job - mandatory
-418 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-419 * @throws RundeckApiLoginException if the login failed
-420 * @throws IllegalArgumentException if the filename or jobId is blank (null, empty or whitespace), or the format is
-421 * null
-422 * @throws IOException if we failed to write to the file
-423 * @see #exportJob(FileType, String)
-424 * @see #getJob(String)
-425 */
-426publicvoid exportJobToFile(String filename, FileType format, String jobId) throws RundeckApiException,
-427 RundeckApiLoginException, IllegalArgumentException, IOException {
-428 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
-429 InputStream inputStream = exportJob(format, jobId);
-430 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
-431 }
-432
-433/**
-434 * Export the definition of a single job, identified by the given ID
-435 *
-436 * @param format of the export. See {@link FileType} - mandatory
-437 * @param jobId identifier of the job - mandatory
-438 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-439 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-440 * @throws RundeckApiLoginException if the login failed
-441 * @throws IllegalArgumentException if the format or jobId is blank (null, empty or whitespace), or the format is
-442 * invalid
-443 * @see #exportJobToFile(String, String, String)
-444 * @see #getJob(String)
-445 */
-446public InputStream exportJob(String format, String jobId) throws RundeckApiException, RundeckApiLoginException,
-447 IllegalArgumentException {
-448 AssertUtil.notBlank(format, "format is mandatory to export a job !");
-449return exportJob(FileType.valueOf(StringUtils.upperCase(format)), jobId);
-450 }
-451
-452/**
-453 * Export the definition of a single job, identified by the given ID
-454 *
-455 * @param format of the export. See {@link FileType} - mandatory
-456 * @param jobId identifier of the job - mandatory
-457 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-458 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-459 * @throws RundeckApiLoginException if the login failed
-460 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the format is null
-461 * @see #exportJobToFile(String, FileType, String)
-462 * @see #getJob(String)
-463 */
-464public InputStream exportJob(FileType format, String jobId) throws RundeckApiException, RundeckApiLoginException,
-465 IllegalArgumentException {
-466 AssertUtil.notNull(format, "format is mandatory to export a job !");
-467 AssertUtil.notBlank(jobId, "jobId is mandatory to export a job !");
-468returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId).param("format", format));
-469 }
-470
-471/**
-472 * Import the definitions of jobs, from the given file
-473 *
-474 * @param filename of the file containing the jobs definitions - mandatory
-475 * @param fileType type of the file. See {@link FileType} - mandatory
-476 * @return a {@link RundeckJobsImportResult} instance - won't be null
-477 * @throws RundeckApiException in case of error when calling the API
-478 * @throws RundeckApiLoginException if the login failed
-479 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
-480 * fileType is invalid
-481 * @throws IOException if we failed to read the file
-482 * @see #importJobs(InputStream, String)
-483 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-484 */
-485publicRundeckJobsImportResult importJobs(String filename, String fileType) throws RundeckApiException,
-486 RundeckApiLoginException, IllegalArgumentException, IOException {
-487 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-488return importJobs(filename, FileType.valueOf(StringUtils.upperCase(fileType)));
-489 }
-490
-491/**
-492 * Import the definitions of jobs, from the given file
-493 *
-494 * @param filename of the file containing the jobs definitions - mandatory
-495 * @param fileType type of the file. See {@link FileType} - mandatory
-496 * @return a {@link RundeckJobsImportResult} instance - won't be null
-497 * @throws RundeckApiException in case of error when calling the API
-498 * @throws RundeckApiLoginException if the login failed
-499 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
-500 * @throws IOException if we failed to read the file
-501 * @see #importJobs(InputStream, FileType)
-502 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-503 */
-504publicRundeckJobsImportResult importJobs(String filename, FileType fileType) throws RundeckApiException,
-505 RundeckApiLoginException, IllegalArgumentException, IOException {
-506return importJobs(filename, fileType, (RundeckJobsImportMethod) null);
-507 }
-508
-509/**
-510 * Import the definitions of jobs, from the given file, using the given behavior
-511 *
-512 * @param filename of the file containing the jobs definitions - mandatory
-513 * @param fileType type of the file. See {@link FileType} - mandatory
-514 * @param importBehavior see {@link RundeckJobsImportMethod}
-515 * @return a {@link RundeckJobsImportResult} instance - won't be null
-516 * @throws RundeckApiException in case of error when calling the API
-517 * @throws RundeckApiLoginException if the login failed
-518 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
-519 * fileType or behavior is not valid
-520 * @throws IOException if we failed to read the file
-521 * @see #importJobs(InputStream, String, String)
-522 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-523 */
-524publicRundeckJobsImportResult importJobs(String filename, String fileType, String importBehavior)
-525throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
-526 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-527return importJobs(filename,
-528 FileType.valueOf(StringUtils.upperCase(fileType)),
-529 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
-530 }
-531
-532/**
-533 * Import the definitions of jobs, from the given file, using the given behavior
-534 *
-535 * @param filename of the file containing the jobs definitions - mandatory
-536 * @param fileType type of the file. See {@link FileType} - mandatory
-537 * @param importBehavior see {@link RundeckJobsImportMethod}
-538 * @return a {@link RundeckJobsImportResult} instance - won't be null
-539 * @throws RundeckApiException in case of error when calling the API
-540 * @throws RundeckApiLoginException if the login failed
-541 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
-542 * @throws IOException if we failed to read the file
-543 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-544 */
-545publicRundeckJobsImportResult importJobs(String filename, FileType fileType, RundeckJobsImportMethod importBehavior)
-546throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
-547 AssertUtil.notBlank(filename, "filename (of jobs file) is mandatory to import jobs !");
-548 FileInputStream stream = null;
-549try {
-550 stream = FileUtils.openInputStream(new File(filename));
-551return importJobs(stream, fileType, importBehavior);
-552 } finally {
-553 IOUtils.closeQuietly(stream);
-554 }
-555 }
-556
-557/**
-558 * Import the definitions of jobs, from the given input stream
-559 *
-560 * @param stream inputStream for reading the definitions - mandatory
-561 * @param fileType type of the file. See {@link FileType} - mandatory
-562 * @return a {@link RundeckJobsImportResult} instance - won't be null
-563 * @throws RundeckApiException in case of error when calling the API
-564 * @throws RundeckApiLoginException if the login failed
-565 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace) or
-566 * invalid
-567 * @see #importJobs(String, String)
-568 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-569 */
-570publicRundeckJobsImportResult importJobs(InputStream stream, String fileType) throws RundeckApiException,
-571 RundeckApiLoginException, IllegalArgumentException {
-572 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-573return importJobs(stream, FileType.valueOf(StringUtils.upperCase(fileType)));
-574 }
-575
-576/**
-577 * Import the definitions of jobs, from the given input stream
-578 *
-579 * @param stream inputStream for reading the definitions - mandatory
-580 * @param fileType type of the file. See {@link FileType} - mandatory
-581 * @return a {@link RundeckJobsImportResult} instance - won't be null
-582 * @throws RundeckApiException in case of error when calling the API
-583 * @throws RundeckApiLoginException if the login failed
-584 * @throws IllegalArgumentException if the stream or fileType is null
-585 * @see #importJobs(String, FileType)
-586 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-587 */
-588publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType) throws RundeckApiException,
-589 RundeckApiLoginException, IllegalArgumentException {
-590return importJobs(stream, fileType, (RundeckJobsImportMethod) null);
-591 }
-592
-593/**
-594 * Import the definitions of jobs, from the given input stream, using the given behavior
-595 *
-596 * @param stream inputStream for reading the definitions - mandatory
-597 * @param fileType type of the file. See {@link FileType} - mandatory
-598 * @param importBehavior see {@link RundeckJobsImportMethod}
-599 * @return a {@link RundeckJobsImportResult} instance - won't be null
-600 * @throws RundeckApiException in case of error when calling the API
-601 * @throws RundeckApiLoginException if the login failed
-602 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace), or
-603 * the fileType or behavior is not valid
-604 * @see #importJobs(String, String, String)
-605 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-606 */
-607publicRundeckJobsImportResult importJobs(InputStream stream, String fileType, String importBehavior)
-608throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-609 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-610return importJobs(stream,
-611 FileType.valueOf(StringUtils.upperCase(fileType)),
-612 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
-613 }
-614
-615/**
-616 * Import the definitions of jobs, from the given input stream, using the given behavior
-617 *
-618 * @param stream inputStream for reading the definitions - mandatory
-619 * @param fileType type of the file. See {@link FileType} - mandatory
-620 * @param importBehavior see {@link RundeckJobsImportMethod}
-621 * @return a {@link RundeckJobsImportResult} instance - won't be null
-622 * @throws RundeckApiException in case of error when calling the API
-623 * @throws RundeckApiLoginException if the login failed
-624 * @throws IllegalArgumentException if the stream or fileType is null
-625 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-626 */
-627publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType,
-628RundeckJobsImportMethod importBehavior) throws RundeckApiException, RundeckApiLoginException,
-629 IllegalArgumentException {
-630 AssertUtil.notNull(stream, "inputStream of jobs is mandatory to import jobs !");
-631 AssertUtil.notNull(fileType, "fileType is mandatory to import jobs !");
-632returnnewApiCall(this).post(newApiPathBuilder("/jobs/import").param("format", fileType)
-633 .param("dupeOption", importBehavior)
-634 .attach("xmlBatch", stream),
-635newJobsImportResultParser("result"));
-636 }
-637
-638/**
-639 * Find a job, identified by its project, group and name. Note that the groupPath is optional, as a job does not
-640 * need to belong to a group (either pass null, or an empty string).
-641 *
-642 * @param project name of the project - mandatory
-643 * @param groupPath group to which the job belongs (if it belongs to a group) - optional
-644 * @param name of the job to find - mandatory
-645 * @return a {@link RundeckJob} instance - null if not found
-646 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-647 * @throws RundeckApiLoginException if the login failed
-648 * @throws IllegalArgumentException if the project or the name is blank (null, empty or whitespace)
-649 * @see #getJob(String)
-650 */
-651publicRundeckJob findJob(String project, String groupPath, String name) throws RundeckApiException,
-652 RundeckApiLoginException, IllegalArgumentException {
-653 AssertUtil.notBlank(project, "project is mandatory to find a job !");
-654 AssertUtil.notBlank(name, "job name is mandatory to find a job !");
-655 List<RundeckJob> jobs = getJobs(project, name, groupPath, new String[0]);
-656return jobs.isEmpty() ? null : jobs.get(0);
-657 }
-658
-659/**
-660 * Get the definition of a single job, identified by the given ID
-661 *
-662 * @param jobId identifier of the job - mandatory
-663 * @return a {@link RundeckJob} instance - won't be null
-664 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-665 * @throws RundeckApiLoginException if the login failed
-666 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-667 * @see #findJob(String, String, String)
-668 * @see #exportJob(String)
-669 */
-670publicRundeckJob getJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-671 IllegalArgumentException {
-672 AssertUtil.notBlank(jobId, "jobId is mandatory to get the details of a job !");
-673returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId), newJobParser("joblist/job"));
-674 }
-675
-676/**
-677 * Delete a single job, identified by the given ID
-678 *
-679 * @param jobId identifier of the job - mandatory
-680 * @return the success message (note that in case of error, you'll get an exception)
-681 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-682 * @throws RundeckApiLoginException if the login failed
-683 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-684 */
-685public String deleteJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-686 IllegalArgumentException {
-687 AssertUtil.notBlank(jobId, "jobId is mandatory to delete a job !");
-688returnnewApiCall(this).delete(newApiPathBuilder("/job/", jobId), newStringParser("result/success/message"));
-689 }
-690
-691/**
-692 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-693 * end of the job execution)
-694 *
-695 * @param jobId identifier of the job - mandatory
-696 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-697 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-698 * @throws RundeckApiLoginException if the login failed
-699 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-700 * @see #triggerJob(String, Properties, Properties)
-701 * @see #runJob(String)
-702 */
-703publicRundeckExecution triggerJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-704 IllegalArgumentException {
-705return triggerJob(jobId, null);
-706 }
-707
-708/**
-709 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-710 * end of the job execution)
-711 *
-712 * @param jobId identifier of the job - mandatory
-713 * @param options of the job - optional. See {@link OptionsBuilder}.
-714 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-715 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-716 * @throws RundeckApiLoginException if the login failed
-717 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-718 * @see #triggerJob(String, Properties, Properties)
-719 * @see #runJob(String, Properties)
-720 */
-721publicRundeckExecution triggerJob(String jobId, Properties options) throws RundeckApiException,
-722 RundeckApiLoginException, IllegalArgumentException {
-723return triggerJob(jobId, options, null);
-724 }
-725
-726/**
-727 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-728 * end of the job execution)
-729 *
-730 * @param jobId identifier of the job - mandatory
-731 * @param options of the job - optional. See {@link OptionsBuilder}.
-732 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-733 * {@link NodeFiltersBuilder}
-734 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-735 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-736 * @throws RundeckApiLoginException if the login failed
-737 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-738 * @see #triggerJob(String)
-739 * @see #runJob(String, Properties, Properties)
-740 */
-741publicRundeckExecution triggerJob(String jobId, Properties options, Properties nodeFilters)
-742throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-743 AssertUtil.notBlank(jobId, "jobId is mandatory to trigger a job !");
-744returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/run").param("argString",
-745 ParametersUtil.generateArgString(options))
-746 .nodeFilters(nodeFilters),
-747newExecutionParser("result/executions/execution"));
-748 }
-749
-750/**
-751 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-752 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-753 * aborted) or is still running.
-754 *
-755 * @param jobId identifier of the job - mandatory
-756 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-757 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-758 * @throws RundeckApiLoginException if the login failed
-759 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-760 * @see #triggerJob(String)
-761 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-762 */
-763publicRundeckExecution runJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-764 IllegalArgumentException {
-765return runJob(jobId, null);
-766 }
-767
-768/**
-769 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-770 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-771 * aborted) or is still running.
-772 *
-773 * @param jobId identifier of the job - mandatory
-774 * @param options of the job - optional. See {@link OptionsBuilder}.
-775 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-776 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-777 * @throws RundeckApiLoginException if the login failed
-778 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-779 * @see #triggerJob(String, Properties)
-780 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-781 */
-782publicRundeckExecution runJob(String jobId, Properties options) throws RundeckApiException,
-783 RundeckApiLoginException, IllegalArgumentException {
-784return runJob(jobId, options, null);
-785 }
-786
-787/**
-788 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-789 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-790 * aborted) or is still running.
-791 *
-792 * @param jobId identifier of the job - mandatory
-793 * @param options of the job - optional. See {@link OptionsBuilder}.
-794 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-795 * {@link NodeFiltersBuilder}
-796 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-797 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-798 * @throws RundeckApiLoginException if the login failed
-799 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-800 * @see #triggerJob(String, Properties, Properties)
-801 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-802 */
-803publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters)
-804throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-805return runJob(jobId, options, nodeFilters, 5, TimeUnit.SECONDS);
-806 }
-807
-808/**
-809 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-810 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
-811 * know if the execution is finished (or aborted) or is still running.
-812 *
-813 * @param jobId identifier of the job - mandatory
-814 * @param options of the job - optional. See {@link OptionsBuilder}.
-815 * @param poolingInterval for checking the status of the execution. Must be > 0.
-816 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-817 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-818 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-819 * @throws RundeckApiLoginException if the login failed
-820 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-821 * @see #triggerJob(String, Properties)
-822 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-823 */
-824publicRundeckExecution runJob(String jobId, Properties options, long poolingInterval, TimeUnit poolingUnit)
-825throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-826return runJob(jobId, options, null, poolingInterval, poolingUnit);
-827 }
-828
-829/**
-830 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-831 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
-832 * know if the execution is finished (or aborted) or is still running.
-833 *
-834 * @param jobId identifier of the job - mandatory
-835 * @param options of the job - optional. See {@link OptionsBuilder}.
-836 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-837 * {@link NodeFiltersBuilder}
-838 * @param poolingInterval for checking the status of the execution. Must be > 0.
-839 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-840 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-841 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-842 * @throws RundeckApiLoginException if the login failed
-843 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-844 * @see #triggerJob(String, Properties)
-845 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-846 */
-847publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters, long poolingInterval,
-848 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-849if (poolingInterval <= 0) {
-850 poolingInterval = 5;
-851 poolingUnit = TimeUnit.SECONDS;
-852 }
-853if (poolingUnit == null) {
-854 poolingUnit = TimeUnit.SECONDS;
-855 }
-856
-857RundeckExecution execution = triggerJob(jobId, options, nodeFilters);
-858while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
-859try {
-860 Thread.sleep(poolingUnit.toMillis(poolingInterval));
-861 } catch (InterruptedException e) {
-862break;
-863 }
-864 execution = getExecution(execution.getId());
-865 }
-866return execution;
-867 }
-868
-869/*
-870 * Ad-hoc commands
-871 */
-872
-873/**
-874 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-875 * The command will not be dispatched to nodes, but be executed on the RunDeck server.
-876 *
-877 * @param project name of the project - mandatory
-878 * @param command to be executed - mandatory
-879 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-880 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-881 * @throws RundeckApiLoginException if the login failed
-882 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-883 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-884 * @see #runAdhocCommand(String, String)
-885 */
-886publicRundeckExecution triggerAdhocCommand(String project, String command) throws RundeckApiException,
-887 RundeckApiLoginException, IllegalArgumentException {
-888return triggerAdhocCommand(project, command, null);
-889 }
-890
-891/**
-892 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-893 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-894 *
-895 * @param project name of the project - mandatory
-896 * @param command to be executed - mandatory
-897 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-898 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-899 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-900 * @throws RundeckApiLoginException if the login failed
-901 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-902 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-903 * @see #runAdhocCommand(String, String, Properties)
-904 */
-905publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters)
-906throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-907return triggerAdhocCommand(project, command, nodeFilters, null, null);
-908 }
-909
-910/**
-911 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-912 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-913 *
-914 * @param project name of the project - mandatory
-915 * @param command to be executed - mandatory
-916 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-917 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-918 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-919 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-920 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-921 * @throws RundeckApiLoginException if the login failed
-922 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-923 * @see #triggerAdhocCommand(String, String)
-924 * @see #runAdhocCommand(String, String, Properties)
-925 */
-926publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters,
-927 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
-928 IllegalArgumentException {
-929 AssertUtil.notBlank(project, "project is mandatory to trigger an ad-hoc command !");
-930 AssertUtil.notBlank(command, "command is mandatory to trigger an ad-hoc command !");
-931RundeckExecution execution = newApiCall(this).get(newApiPathBuilder("/run/command").param("project", project)
-932 .param("exec", command)
-933 .param("nodeThreadcount",
-934 nodeThreadcount)
-935 .param("nodeKeepgoing",
-936 nodeKeepgoing)
-937 .nodeFilters(nodeFilters),
-938newExecutionParser("result/execution"));
-939// the first call just returns the ID of the execution, so we need another call to get a "real" execution
-940return getExecution(execution.getId());
-941 }
-942
-943/**
-944 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-945 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-946 * running. The command will not be dispatched to nodes, but be executed on the RunDeck server.
-947 *
-948 * @param project name of the project - mandatory
-949 * @param command to be executed - mandatory
-950 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-951 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-952 * @throws RundeckApiLoginException if the login failed
-953 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-954 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-955 * @see #triggerAdhocCommand(String, String)
-956 */
-957publicRundeckExecution runAdhocCommand(String project, String command) throws RundeckApiException,
-958 RundeckApiLoginException, IllegalArgumentException {
-959return runAdhocCommand(project, command, null);
-960 }
-961
-962/**
-963 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-964 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-965 * finished (or aborted) or is still running. The command will not be dispatched to nodes, but be executed on the
-966 * RunDeck server.
-967 *
-968 * @param project name of the project - mandatory
-969 * @param command to be executed - mandatory
-970 * @param poolingInterval for checking the status of the execution. Must be > 0.
-971 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-972 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-973 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-974 * @throws RundeckApiLoginException if the login failed
-975 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-976 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-977 * @see #triggerAdhocCommand(String, String)
-978 */
-979publicRundeckExecution runAdhocCommand(String project, String command, long poolingInterval, TimeUnit poolingUnit)
-980throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-981return runAdhocCommand(project, command, null, poolingInterval, poolingUnit);
-982 }
-983
-984/**
-985 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-986 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-987 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-988 *
-989 * @param project name of the project - mandatory
-990 * @param command to be executed - mandatory
-991 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-992 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-993 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-994 * @throws RundeckApiLoginException if the login failed
-995 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-996 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-997 * @see #triggerAdhocCommand(String, String, Properties)
-998 */
-999publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters)
-1000throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-1001return runAdhocCommand(project, command, nodeFilters, null, null);
-1002 }
-1003
-1004/**
-1005 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1006 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1007 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
-1008 * nodeFilters parameter.
-1009 *
-1010 * @param project name of the project - mandatory
-1011 * @param command to be executed - mandatory
-1012 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1013 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1014 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1015 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1016 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1017 * @throws RundeckApiLoginException if the login failed
-1018 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1019 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1020 * @see #triggerAdhocCommand(String, String, Properties)
-1021 */
-1022publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1023long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
-1024 IllegalArgumentException {
-1025return runAdhocCommand(project, command, nodeFilters, null, null, poolingInterval, poolingUnit);
-1026 }
-1027
-1028/**
-1029 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1030 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1031 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1032 *
-1033 * @param project name of the project - mandatory
-1034 * @param command to be executed - mandatory
-1035 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1036 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1037 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1038 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1039 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1040 * @throws RundeckApiLoginException if the login failed
-1041 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1042 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1043 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1044 */
-1045publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1046 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
-1047 IllegalArgumentException {
-1048return runAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing, 5, TimeUnit.SECONDS);
-1049 }
-1050
-1051/**
-1052 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1053 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1054 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
-1055 * nodeFilters parameter.
-1056 *
-1057 * @param project name of the project - mandatory
-1058 * @param command to be executed - mandatory
-1059 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1060 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1061 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1062 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1063 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1064 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1065 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1066 * @throws RundeckApiLoginException if the login failed
-1067 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1068 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1069 */
-1070publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1071 Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval, TimeUnit poolingUnit)
-1072throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-1073if (poolingInterval <= 0) {
-1074 poolingInterval = 5;
-1075 poolingUnit = TimeUnit.SECONDS;
-1076 }
-1077if (poolingUnit == null) {
-1078 poolingUnit = TimeUnit.SECONDS;
-1079 }
-1080
-1081RundeckExecution execution = triggerAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing);
-1082while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
-1083try {
-1084 Thread.sleep(poolingUnit.toMillis(poolingInterval));
-1085 } catch (InterruptedException e) {
-1086break;
-1087 }
-1088 execution = getExecution(execution.getId());
-1089 }
-1090return execution;
-1091 }
-1092
-1093/*
-1094 * Executions
-1095 */
-1096
-1097/**
-1098 * Get all running executions (for all projects)
-1099 *
-1100 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1101 * @throws RundeckApiException in case of error when calling the API
-1102 * @throws RundeckApiLoginException if the login failed
-1103 * @see #getRunningExecutions(String)
-1104 */
-1105public List<RundeckExecution> getRunningExecutions() throws RundeckApiException, RundeckApiLoginException {
-1106 List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
-1107for (RundeckProject project : getProjects()) {
-1108 executions.addAll(getRunningExecutions(project.getName()));
+149public List<RundeckProject> getProjects() throws RundeckApiException, RundeckApiLoginException {
+150returnnewApiCall(this).get(newApiPathBuilder("/projects"),
+151new ListParser<RundeckProject>(newProjectParser(), "result/projects/project"));
+152 }
+153
+154/**
+155 * Get the definition of a single project, identified by the given name
+156 *
+157 * @param projectName name of the project - mandatory
+158 * @return a {@link RundeckProject} instance - won't be null
+159 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+160 * @throws RundeckApiLoginException if the login failed
+161 * @throws IllegalArgumentException if the projectName is blank (null, empty or whitespace)
+162 */
+163publicRundeckProject getProject(String projectName) throws RundeckApiException, RundeckApiLoginException,
+164 IllegalArgumentException {
+165 AssertUtil.notBlank(projectName, "projectName is mandatory to get the details of a project !");
+166returnnewApiCall(this).get(newApiPathBuilder("/project/", projectName),
+167newProjectParser("result/projects/project"));
+168 }
+169
+170/*
+171 * Jobs
+172 */
+173
+174/**
+175 * List all jobs (for all projects)
+176 *
+177 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
+178 * @throws RundeckApiException in case of error when calling the API
+179 * @throws RundeckApiLoginException if the login failed
+180 */
+181public List<RundeckJob> getJobs() throws RundeckApiException, RundeckApiLoginException {
+182 List<RundeckJob> jobs = new ArrayList<RundeckJob>();
+183for (RundeckProject project : getProjects()) {
+184 jobs.addAll(getJobs(project.getName()));
+185 }
+186return jobs;
+187 }
+188
+189/**
+190 * List all jobs that belongs to the given project
+191 *
+192 * @param project name of the project - mandatory
+193 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
+194 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+195 * @throws RundeckApiLoginException if the login failed
+196 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+197 * @see #getJobs(String, String, String, String...)
+198 */
+199public List<RundeckJob> getJobs(String project) throws RundeckApiException, RundeckApiLoginException,
+200 IllegalArgumentException {
+201return getJobs(project, null, null, new String[0]);
+202 }
+203
+204/**
+205 * List the jobs that belongs to the given project, and matches the given criteria (jobFilter, groupPath and jobIds)
+206 *
+207 * @param project name of the project - mandatory
+208 * @param jobFilter a filter for the job Name - optional
+209 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+210 * @param jobIds a list of Job IDs to include - optional
+211 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
+212 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+213 * @throws RundeckApiLoginException if the login failed
+214 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+215 * @see #getJobs(String)
+216 */
+217public List<RundeckJob> getJobs(String project, String jobFilter, String groupPath, String... jobIds)
+218throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+219 AssertUtil.notBlank(project, "project is mandatory to get all jobs !");
+220returnnewApiCall(this).get(newApiPathBuilder("/jobs").param("project", project)
+221 .param("jobFilter", jobFilter)
+222 .param("groupPath", groupPath)
+223 .param("idlist", StringUtils.join(jobIds, ",")),
+224new ListParser<RundeckJob>(newJobParser(), "result/jobs/job"));
+225 }
+226
+227/**
+228 * Export the definitions of all jobs that belongs to the given project
+229 *
+230 * @param filename path of the file where the content should be saved - mandatory
+231 * @param format of the export. See {@link FileType} - mandatory
+232 * @param project name of the project - mandatory
+233 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+234 * @throws RundeckApiLoginException if the login failed
+235 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+236 * invalid
+237 * @throws IOException if we failed to write to the file
+238 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+239 * @see #exportJobs(String, String)
+240 */
+241publicvoid exportJobsToFile(String filename, String format, String project) throws RundeckApiException,
+242 RundeckApiLoginException, IllegalArgumentException, IOException {
+243 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+244 exportJobsToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), project);
+245 }
+246
+247/**
+248 * Export the definitions of all jobs that belongs to the given project
+249 *
+250 * @param filename path of the file where the content should be saved - mandatory
+251 * @param format of the export. See {@link FileType} - mandatory
+252 * @param project name of the project - mandatory
+253 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+254 * @throws RundeckApiLoginException if the login failed
+255 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+256 * @throws IOException if we failed to write to the file
+257 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+258 * @see #exportJobs(FileType, String)
+259 */
+260publicvoid exportJobsToFile(String filename, FileType format, String project) throws RundeckApiException,
+261 RundeckApiLoginException, IllegalArgumentException, IOException {
+262 exportJobsToFile(filename, format, project, null, null, new String[0]);
+263 }
+264
+265/**
+266 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+267 * groupPath and jobIds)
+268 *
+269 * @param filename path of the file where the content should be saved - mandatory
+270 * @param format of the export. See {@link FileType} - mandatory
+271 * @param project name of the project - mandatory
+272 * @param jobFilter a filter for the job Name - optional
+273 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+274 * @param jobIds a list of Job IDs to include - optional
+275 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+276 * @throws RundeckApiLoginException if the login failed
+277 * @throws IllegalArgumentException if the filename, format or project is blank (null, empty or whitespace), or the
+278 * format is invalid
+279 * @throws IOException if we failed to write to the file
+280 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+281 * @see #exportJobs(FileType, String, String, String, String...)
+282 */
+283publicvoid exportJobsToFile(String filename, String format, String project, String jobFilter, String groupPath,
+284 String... jobIds) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+285 IOException {
+286 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+287 exportJobsToFile(filename,
+288 FileType.valueOf(StringUtils.upperCase(format)),
+289 project,
+290 jobFilter,
+291 groupPath,
+292 jobIds);
+293 }
+294
+295/**
+296 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+297 * groupPath and jobIds)
+298 *
+299 * @param filename path of the file where the content should be saved - mandatory
+300 * @param format of the export. See {@link FileType} - mandatory
+301 * @param project name of the project - mandatory
+302 * @param jobFilter a filter for the job Name - optional
+303 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+304 * @param jobIds a list of Job IDs to include - optional
+305 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+306 * @throws RundeckApiLoginException if the login failed
+307 * @throws IllegalArgumentException if the filename or project is blank (null, empty or whitespace), or the format
+308 * is null
+309 * @throws IOException if we failed to write to the file
+310 * @see #exportJobs(FileType, String, String, String, String...)
+311 */
+312publicvoid exportJobsToFile(String filename, FileType format, String project, String jobFilter, String groupPath,
+313 String... jobIds) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+314 IOException {
+315 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
+316 InputStream inputStream = exportJobs(format, project, jobFilter, groupPath, jobIds);
+317 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
+318 }
+319
+320/**
+321 * Export the definitions of all jobs that belongs to the given project
+322 *
+323 * @param format of the export. See {@link FileType} - mandatory
+324 * @param project name of the project - mandatory
+325 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+326 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+327 * @throws RundeckApiLoginException if the login failed
+328 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+329 * invalid
+330 * @see #exportJobs(FileType, String, String, String, String...)
+331 * @see #exportJobsToFile(String, String, String)
+332 */
+333public InputStream exportJobs(String format, String project) throws RundeckApiException, RundeckApiLoginException,
+334 IllegalArgumentException {
+335 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+336return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project);
+337 }
+338
+339/**
+340 * Export the definitions of all jobs that belongs to the given project
+341 *
+342 * @param format of the export. See {@link FileType} - mandatory
+343 * @param project name of the project - mandatory
+344 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+345 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+346 * @throws RundeckApiLoginException if the login failed
+347 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+348 * @see #exportJobs(FileType, String, String, String, String...)
+349 * @see #exportJobsToFile(String, FileType, String)
+350 */
+351public InputStream exportJobs(FileType format, String project) throws RundeckApiException,
+352 RundeckApiLoginException, IllegalArgumentException {
+353return exportJobs(format, project, null, null, new String[0]);
+354 }
+355
+356/**
+357 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+358 * groupPath and jobIds)
+359 *
+360 * @param format of the export. See {@link FileType} - mandatory
+361 * @param project name of the project - mandatory
+362 * @param jobFilter a filter for the job Name - optional
+363 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+364 * @param jobIds a list of Job IDs to include - optional
+365 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+366 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+367 * @throws RundeckApiLoginException if the login failed
+368 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+369 * invalid
+370 * @see #exportJobs(FileType, String, String, String, String...)
+371 * @see #exportJobsToFile(String, String, String, String, String, String...)
+372 */
+373public InputStream exportJobs(String format, String project, String jobFilter, String groupPath, String... jobIds)
+374throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+375 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+376return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project, jobFilter, groupPath, jobIds);
+377 }
+378
+379/**
+380 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+381 * groupPath and jobIds)
+382 *
+383 * @param format of the export. See {@link FileType} - mandatory
+384 * @param project name of the project - mandatory
+385 * @param jobFilter a filter for the job Name - optional
+386 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+387 * @param jobIds a list of Job IDs to include - optional
+388 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+389 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+390 * @throws RundeckApiLoginException if the login failed
+391 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+392 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+393 */
+394public InputStream exportJobs(FileType format, String project, String jobFilter, String groupPath, String... jobIds)
+395throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+396 AssertUtil.notNull(format, "format is mandatory to export jobs !");
+397 AssertUtil.notBlank(project, "project is mandatory to export jobs !");
+398returnnewApiCall(this).get(newApiPathBuilder("/jobs/export").param("format", format)
+399 .param("project", project)
+400 .param("jobFilter", jobFilter)
+401 .param("groupPath", groupPath)
+402 .param("idlist", StringUtils.join(jobIds, ",")));
+403 }
+404
+405/**
+406 * Export the definition of a single job (identified by the given ID)
+407 *
+408 * @param filename path of the file where the content should be saved - mandatory
+409 * @param format of the export. See {@link FileType} - mandatory
+410 * @param jobId identifier of the job - mandatory
+411 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+412 * @throws RundeckApiLoginException if the login failed
+413 * @throws IllegalArgumentException if the filename, format or jobId is blank (null, empty or whitespace), or the
+414 * format is invalid
+415 * @throws IOException if we failed to write to the file
+416 * @see #exportJobToFile(String, FileType, String)
+417 * @see #exportJob(String, String)
+418 * @see #getJob(String)
+419 */
+420publicvoid exportJobToFile(String filename, String format, String jobId) throws RundeckApiException,
+421 RundeckApiLoginException, IllegalArgumentException, IOException {
+422 AssertUtil.notBlank(format, "format is mandatory to export a job !");
+423 exportJobToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), jobId);
+424 }
+425
+426/**
+427 * Export the definition of a single job (identified by the given ID)
+428 *
+429 * @param filename path of the file where the content should be saved - mandatory
+430 * @param format of the export. See {@link FileType} - mandatory
+431 * @param jobId identifier of the job - mandatory
+432 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+433 * @throws RundeckApiLoginException if the login failed
+434 * @throws IllegalArgumentException if the filename or jobId is blank (null, empty or whitespace), or the format is
+435 * null
+436 * @throws IOException if we failed to write to the file
+437 * @see #exportJob(FileType, String)
+438 * @see #getJob(String)
+439 */
+440publicvoid exportJobToFile(String filename, FileType format, String jobId) throws RundeckApiException,
+441 RundeckApiLoginException, IllegalArgumentException, IOException {
+442 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
+443 InputStream inputStream = exportJob(format, jobId);
+444 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
+445 }
+446
+447/**
+448 * Export the definition of a single job, identified by the given ID
+449 *
+450 * @param format of the export. See {@link FileType} - mandatory
+451 * @param jobId identifier of the job - mandatory
+452 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+453 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+454 * @throws RundeckApiLoginException if the login failed
+455 * @throws IllegalArgumentException if the format or jobId is blank (null, empty or whitespace), or the format is
+456 * invalid
+457 * @see #exportJobToFile(String, String, String)
+458 * @see #getJob(String)
+459 */
+460public InputStream exportJob(String format, String jobId) throws RundeckApiException, RundeckApiLoginException,
+461 IllegalArgumentException {
+462 AssertUtil.notBlank(format, "format is mandatory to export a job !");
+463return exportJob(FileType.valueOf(StringUtils.upperCase(format)), jobId);
+464 }
+465
+466/**
+467 * Export the definition of a single job, identified by the given ID
+468 *
+469 * @param format of the export. See {@link FileType} - mandatory
+470 * @param jobId identifier of the job - mandatory
+471 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+472 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+473 * @throws RundeckApiLoginException if the login failed
+474 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the format is null
+475 * @see #exportJobToFile(String, FileType, String)
+476 * @see #getJob(String)
+477 */
+478public InputStream exportJob(FileType format, String jobId) throws RundeckApiException, RundeckApiLoginException,
+479 IllegalArgumentException {
+480 AssertUtil.notNull(format, "format is mandatory to export a job !");
+481 AssertUtil.notBlank(jobId, "jobId is mandatory to export a job !");
+482returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId).param("format", format));
+483 }
+484
+485/**
+486 * Import the definitions of jobs, from the given file
+487 *
+488 * @param filename of the file containing the jobs definitions - mandatory
+489 * @param fileType type of the file. See {@link FileType} - mandatory
+490 * @return a {@link RundeckJobsImportResult} instance - won't be null
+491 * @throws RundeckApiException in case of error when calling the API
+492 * @throws RundeckApiLoginException if the login failed
+493 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
+494 * fileType is invalid
+495 * @throws IOException if we failed to read the file
+496 * @see #importJobs(InputStream, String)
+497 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+498 */
+499publicRundeckJobsImportResult importJobs(String filename, String fileType) throws RundeckApiException,
+500 RundeckApiLoginException, IllegalArgumentException, IOException {
+501 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+502return importJobs(filename, FileType.valueOf(StringUtils.upperCase(fileType)));
+503 }
+504
+505/**
+506 * Import the definitions of jobs, from the given file
+507 *
+508 * @param filename of the file containing the jobs definitions - mandatory
+509 * @param fileType type of the file. See {@link FileType} - mandatory
+510 * @return a {@link RundeckJobsImportResult} instance - won't be null
+511 * @throws RundeckApiException in case of error when calling the API
+512 * @throws RundeckApiLoginException if the login failed
+513 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
+514 * @throws IOException if we failed to read the file
+515 * @see #importJobs(InputStream, FileType)
+516 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+517 */
+518publicRundeckJobsImportResult importJobs(String filename, FileType fileType) throws RundeckApiException,
+519 RundeckApiLoginException, IllegalArgumentException, IOException {
+520return importJobs(filename, fileType, (RundeckJobsImportMethod) null);
+521 }
+522
+523/**
+524 * Import the definitions of jobs, from the given file, using the given behavior
+525 *
+526 * @param filename of the file containing the jobs definitions - mandatory
+527 * @param fileType type of the file. See {@link FileType} - mandatory
+528 * @param importBehavior see {@link RundeckJobsImportMethod}
+529 * @return a {@link RundeckJobsImportResult} instance - won't be null
+530 * @throws RundeckApiException in case of error when calling the API
+531 * @throws RundeckApiLoginException if the login failed
+532 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
+533 * fileType or behavior is not valid
+534 * @throws IOException if we failed to read the file
+535 * @see #importJobs(InputStream, String, String)
+536 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+537 */
+538publicRundeckJobsImportResult importJobs(String filename, String fileType, String importBehavior)
+539throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
+540 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+541return importJobs(filename,
+542 FileType.valueOf(StringUtils.upperCase(fileType)),
+543 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
+544 }
+545
+546/**
+547 * Import the definitions of jobs, from the given file, using the given behavior
+548 *
+549 * @param filename of the file containing the jobs definitions - mandatory
+550 * @param fileType type of the file. See {@link FileType} - mandatory
+551 * @param importBehavior see {@link RundeckJobsImportMethod}
+552 * @return a {@link RundeckJobsImportResult} instance - won't be null
+553 * @throws RundeckApiException in case of error when calling the API
+554 * @throws RundeckApiLoginException if the login failed
+555 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
+556 * @throws IOException if we failed to read the file
+557 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+558 */
+559publicRundeckJobsImportResult importJobs(String filename, FileType fileType, RundeckJobsImportMethod importBehavior)
+560throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
+561 AssertUtil.notBlank(filename, "filename (of jobs file) is mandatory to import jobs !");
+562 FileInputStream stream = null;
+563try {
+564 stream = FileUtils.openInputStream(new File(filename));
+565return importJobs(stream, fileType, importBehavior);
+566 } finally {
+567 IOUtils.closeQuietly(stream);
+568 }
+569 }
+570
+571/**
+572 * Import the definitions of jobs, from the given input stream
+573 *
+574 * @param stream inputStream for reading the definitions - mandatory
+575 * @param fileType type of the file. See {@link FileType} - mandatory
+576 * @return a {@link RundeckJobsImportResult} instance - won't be null
+577 * @throws RundeckApiException in case of error when calling the API
+578 * @throws RundeckApiLoginException if the login failed
+579 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace) or
+580 * invalid
+581 * @see #importJobs(String, String)
+582 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+583 */
+584publicRundeckJobsImportResult importJobs(InputStream stream, String fileType) throws RundeckApiException,
+585 RundeckApiLoginException, IllegalArgumentException {
+586 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+587return importJobs(stream, FileType.valueOf(StringUtils.upperCase(fileType)));
+588 }
+589
+590/**
+591 * Import the definitions of jobs, from the given input stream
+592 *
+593 * @param stream inputStream for reading the definitions - mandatory
+594 * @param fileType type of the file. See {@link FileType} - mandatory
+595 * @return a {@link RundeckJobsImportResult} instance - won't be null
+596 * @throws RundeckApiException in case of error when calling the API
+597 * @throws RundeckApiLoginException if the login failed
+598 * @throws IllegalArgumentException if the stream or fileType is null
+599 * @see #importJobs(String, FileType)
+600 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+601 */
+602publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType) throws RundeckApiException,
+603 RundeckApiLoginException, IllegalArgumentException {
+604return importJobs(stream, fileType, (RundeckJobsImportMethod) null);
+605 }
+606
+607/**
+608 * Import the definitions of jobs, from the given input stream, using the given behavior
+609 *
+610 * @param stream inputStream for reading the definitions - mandatory
+611 * @param fileType type of the file. See {@link FileType} - mandatory
+612 * @param importBehavior see {@link RundeckJobsImportMethod}
+613 * @return a {@link RundeckJobsImportResult} instance - won't be null
+614 * @throws RundeckApiException in case of error when calling the API
+615 * @throws RundeckApiLoginException if the login failed
+616 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace), or
+617 * the fileType or behavior is not valid
+618 * @see #importJobs(String, String, String)
+619 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+620 */
+621publicRundeckJobsImportResult importJobs(InputStream stream, String fileType, String importBehavior)
+622throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+623 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+624return importJobs(stream,
+625 FileType.valueOf(StringUtils.upperCase(fileType)),
+626 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
+627 }
+628
+629/**
+630 * Import the definitions of jobs, from the given input stream, using the given behavior
+631 *
+632 * @param stream inputStream for reading the definitions - mandatory
+633 * @param fileType type of the file. See {@link FileType} - mandatory
+634 * @param importBehavior see {@link RundeckJobsImportMethod}
+635 * @return a {@link RundeckJobsImportResult} instance - won't be null
+636 * @throws RundeckApiException in case of error when calling the API
+637 * @throws RundeckApiLoginException if the login failed
+638 * @throws IllegalArgumentException if the stream or fileType is null
+639 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+640 */
+641publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType,
+642RundeckJobsImportMethod importBehavior) throws RundeckApiException, RundeckApiLoginException,
+643 IllegalArgumentException {
+644 AssertUtil.notNull(stream, "inputStream of jobs is mandatory to import jobs !");
+645 AssertUtil.notNull(fileType, "fileType is mandatory to import jobs !");
+646returnnewApiCall(this).post(newApiPathBuilder("/jobs/import").param("format", fileType)
+647 .param("dupeOption", importBehavior)
+648 .attach("xmlBatch", stream),
+649newJobsImportResultParser("result"));
+650 }
+651
+652/**
+653 * Find a job, identified by its project, group and name. Note that the groupPath is optional, as a job does not
+654 * need to belong to a group (either pass null, or an empty string).
+655 *
+656 * @param project name of the project - mandatory
+657 * @param groupPath group to which the job belongs (if it belongs to a group) - optional
+658 * @param name of the job to find - mandatory
+659 * @return a {@link RundeckJob} instance - null if not found
+660 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+661 * @throws RundeckApiLoginException if the login failed
+662 * @throws IllegalArgumentException if the project or the name is blank (null, empty or whitespace)
+663 * @see #getJob(String)
+664 */
+665publicRundeckJob findJob(String project, String groupPath, String name) throws RundeckApiException,
+666 RundeckApiLoginException, IllegalArgumentException {
+667 AssertUtil.notBlank(project, "project is mandatory to find a job !");
+668 AssertUtil.notBlank(name, "job name is mandatory to find a job !");
+669 List<RundeckJob> jobs = getJobs(project, name, groupPath, new String[0]);
+670return jobs.isEmpty() ? null : jobs.get(0);
+671 }
+672
+673/**
+674 * Get the definition of a single job, identified by the given ID
+675 *
+676 * @param jobId identifier of the job - mandatory
+677 * @return a {@link RundeckJob} instance - won't be null
+678 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+679 * @throws RundeckApiLoginException if the login failed
+680 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+681 * @see #findJob(String, String, String)
+682 * @see #exportJob(String, String)
+683 */
+684publicRundeckJob getJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+685 IllegalArgumentException {
+686 AssertUtil.notBlank(jobId, "jobId is mandatory to get the details of a job !");
+687returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId), newJobParser("joblist/job"));
+688 }
+689
+690/**
+691 * Delete a single job, identified by the given ID
+692 *
+693 * @param jobId identifier of the job - mandatory
+694 * @return the success message (note that in case of error, you'll get an exception)
+695 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+696 * @throws RundeckApiLoginException if the login failed
+697 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+698 */
+699public String deleteJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+700 IllegalArgumentException {
+701 AssertUtil.notBlank(jobId, "jobId is mandatory to delete a job !");
+702returnnewApiCall(this).delete(newApiPathBuilder("/job/", jobId), newStringParser("result/success/message"));
+703 }
+704
+705/**
+706 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+707 * end of the job execution)
+708 *
+709 * @param jobId identifier of the job - mandatory
+710 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+711 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+712 * @throws RundeckApiLoginException if the login failed
+713 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+714 * @see #triggerJob(String, Properties, Properties)
+715 * @see #runJob(String)
+716 */
+717publicRundeckExecution triggerJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+718 IllegalArgumentException {
+719return triggerJob(jobId, null);
+720 }
+721
+722/**
+723 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+724 * end of the job execution)
+725 *
+726 * @param jobId identifier of the job - mandatory
+727 * @param options of the job - optional. See {@link OptionsBuilder}.
+728 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+729 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+730 * @throws RundeckApiLoginException if the login failed
+731 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+732 * @see #triggerJob(String, Properties, Properties)
+733 * @see #runJob(String, Properties)
+734 */
+735publicRundeckExecution triggerJob(String jobId, Properties options) throws RundeckApiException,
+736 RundeckApiLoginException, IllegalArgumentException {
+737return triggerJob(jobId, options, null);
+738 }
+739
+740/**
+741 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+742 * end of the job execution)
+743 *
+744 * @param jobId identifier of the job - mandatory
+745 * @param options of the job - optional. See {@link OptionsBuilder}.
+746 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+747 * {@link NodeFiltersBuilder}
+748 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+749 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+750 * @throws RundeckApiLoginException if the login failed
+751 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+752 * @see #triggerJob(String)
+753 * @see #runJob(String, Properties, Properties)
+754 */
+755publicRundeckExecution triggerJob(String jobId, Properties options, Properties nodeFilters)
+756throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+757 AssertUtil.notBlank(jobId, "jobId is mandatory to trigger a job !");
+758returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/run").param("argString",
+759 ParametersUtil.generateArgString(options))
+760 .nodeFilters(nodeFilters),
+761newExecutionParser("result/executions/execution"));
+762 }
+763
+764/**
+765 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+766 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+767 * aborted) or is still running.
+768 *
+769 * @param jobId identifier of the job - mandatory
+770 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+771 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+772 * @throws RundeckApiLoginException if the login failed
+773 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+774 * @see #triggerJob(String)
+775 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+776 */
+777publicRundeckExecution runJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+778 IllegalArgumentException {
+779return runJob(jobId, null);
+780 }
+781
+782/**
+783 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+784 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+785 * aborted) or is still running.
+786 *
+787 * @param jobId identifier of the job - mandatory
+788 * @param options of the job - optional. See {@link OptionsBuilder}.
+789 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+790 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+791 * @throws RundeckApiLoginException if the login failed
+792 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+793 * @see #triggerJob(String, Properties)
+794 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+795 */
+796publicRundeckExecution runJob(String jobId, Properties options) throws RundeckApiException,
+797 RundeckApiLoginException, IllegalArgumentException {
+798return runJob(jobId, options, null);
+799 }
+800
+801/**
+802 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+803 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+804 * aborted) or is still running.
+805 *
+806 * @param jobId identifier of the job - mandatory
+807 * @param options of the job - optional. See {@link OptionsBuilder}.
+808 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+809 * {@link NodeFiltersBuilder}
+810 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+811 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+812 * @throws RundeckApiLoginException if the login failed
+813 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+814 * @see #triggerJob(String, Properties, Properties)
+815 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+816 */
+817publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters)
+818throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+819return runJob(jobId, options, nodeFilters, DEFAULT_POOLING_INTERVAL, DEFAULT_POOLING_UNIT);
+820 }
+821
+822/**
+823 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+824 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+825 * know if the execution is finished (or aborted) or is still running.
+826 *
+827 * @param jobId identifier of the job - mandatory
+828 * @param options of the job - optional. See {@link OptionsBuilder}.
+829 * @param poolingInterval for checking the status of the execution. Must be > 0.
+830 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+831 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+832 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+833 * @throws RundeckApiLoginException if the login failed
+834 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+835 * @see #triggerJob(String, Properties)
+836 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+837 */
+838publicRundeckExecution runJob(String jobId, Properties options, long poolingInterval, TimeUnit poolingUnit)
+839throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+840return runJob(jobId, options, null, poolingInterval, poolingUnit);
+841 }
+842
+843/**
+844 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+845 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+846 * know if the execution is finished (or aborted) or is still running.
+847 *
+848 * @param jobId identifier of the job - mandatory
+849 * @param options of the job - optional. See {@link OptionsBuilder}.
+850 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+851 * {@link NodeFiltersBuilder}
+852 * @param poolingInterval for checking the status of the execution. Must be > 0.
+853 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+854 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+855 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+856 * @throws RundeckApiLoginException if the login failed
+857 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+858 * @see #triggerJob(String, Properties)
+859 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+860 */
+861publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters, long poolingInterval,
+862 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+863if (poolingInterval <= 0) {
+864 poolingInterval = DEFAULT_POOLING_INTERVAL;
+865 poolingUnit = DEFAULT_POOLING_UNIT;
+866 }
+867if (poolingUnit == null) {
+868 poolingUnit = DEFAULT_POOLING_UNIT;
+869 }
+870
+871RundeckExecution execution = triggerJob(jobId, options, nodeFilters);
+872while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+873try {
+874 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+875 } catch (InterruptedException e) {
+876break;
+877 }
+878 execution = getExecution(execution.getId());
+879 }
+880return execution;
+881 }
+882
+883/*
+884 * Ad-hoc commands
+885 */
+886
+887/**
+888 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+889 * The command will not be dispatched to nodes, but be executed on the RunDeck server.
+890 *
+891 * @param project name of the project - mandatory
+892 * @param command to be executed - mandatory
+893 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+894 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+895 * @throws RundeckApiLoginException if the login failed
+896 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+897 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+898 * @see #runAdhocCommand(String, String)
+899 */
+900publicRundeckExecution triggerAdhocCommand(String project, String command) throws RundeckApiException,
+901 RundeckApiLoginException, IllegalArgumentException {
+902return triggerAdhocCommand(project, command, null);
+903 }
+904
+905/**
+906 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+907 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+908 *
+909 * @param project name of the project - mandatory
+910 * @param command to be executed - mandatory
+911 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+912 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+913 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+914 * @throws RundeckApiLoginException if the login failed
+915 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+916 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+917 * @see #runAdhocCommand(String, String, Properties)
+918 */
+919publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters)
+920throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+921return triggerAdhocCommand(project, command, nodeFilters, null, null);
+922 }
+923
+924/**
+925 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+926 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+927 *
+928 * @param project name of the project - mandatory
+929 * @param command to be executed - mandatory
+930 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+931 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+932 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+933 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+934 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+935 * @throws RundeckApiLoginException if the login failed
+936 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+937 * @see #triggerAdhocCommand(String, String)
+938 * @see #runAdhocCommand(String, String, Properties)
+939 */
+940publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters,
+941 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
+942 IllegalArgumentException {
+943 AssertUtil.notBlank(project, "project is mandatory to trigger an ad-hoc command !");
+944 AssertUtil.notBlank(command, "command is mandatory to trigger an ad-hoc command !");
+945RundeckExecution execution = newApiCall(this).get(newApiPathBuilder("/run/command").param("project", project)
+946 .param("exec", command)
+947 .param("nodeThreadcount",
+948 nodeThreadcount)
+949 .param("nodeKeepgoing",
+950 nodeKeepgoing)
+951 .nodeFilters(nodeFilters),
+952newExecutionParser("result/execution"));
+953// the first call just returns the ID of the execution, so we need another call to get a "real" execution
+954return getExecution(execution.getId());
+955 }
+956
+957/**
+958 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+959 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+960 * running. The command will not be dispatched to nodes, but be executed on the RunDeck server.
+961 *
+962 * @param project name of the project - mandatory
+963 * @param command to be executed - mandatory
+964 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+965 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+966 * @throws RundeckApiLoginException if the login failed
+967 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+968 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+969 * @see #triggerAdhocCommand(String, String)
+970 */
+971publicRundeckExecution runAdhocCommand(String project, String command) throws RundeckApiException,
+972 RundeckApiLoginException, IllegalArgumentException {
+973return runAdhocCommand(project, command, null);
+974 }
+975
+976/**
+977 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+978 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+979 * finished (or aborted) or is still running. The command will not be dispatched to nodes, but be executed on the
+980 * RunDeck server.
+981 *
+982 * @param project name of the project - mandatory
+983 * @param command to be executed - mandatory
+984 * @param poolingInterval for checking the status of the execution. Must be > 0.
+985 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+986 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+987 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+988 * @throws RundeckApiLoginException if the login failed
+989 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+990 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+991 * @see #triggerAdhocCommand(String, String)
+992 */
+993publicRundeckExecution runAdhocCommand(String project, String command, long poolingInterval, TimeUnit poolingUnit)
+994throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+995return runAdhocCommand(project, command, null, poolingInterval, poolingUnit);
+996 }
+997
+998/**
+999 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1000 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1001 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1002 *
+1003 * @param project name of the project - mandatory
+1004 * @param command to be executed - mandatory
+1005 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1006 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1007 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1008 * @throws RundeckApiLoginException if the login failed
+1009 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1010 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1011 * @see #triggerAdhocCommand(String, String, Properties)
+1012 */
+1013publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters)
+1014throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1015return runAdhocCommand(project, command, nodeFilters, null, null);
+1016 }
+1017
+1018/**
+1019 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1020 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1021 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1022 * nodeFilters parameter.
+1023 *
+1024 * @param project name of the project - mandatory
+1025 * @param command to be executed - mandatory
+1026 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1027 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1028 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1029 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1030 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1031 * @throws RundeckApiLoginException if the login failed
+1032 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1033 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1034 * @see #triggerAdhocCommand(String, String, Properties)
+1035 */
+1036publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1037long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+1038 IllegalArgumentException {
+1039return runAdhocCommand(project, command, nodeFilters, null, null, poolingInterval, poolingUnit);
+1040 }
+1041
+1042/**
+1043 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1044 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1045 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1046 *
+1047 * @param project name of the project - mandatory
+1048 * @param command to be executed - mandatory
+1049 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1050 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1051 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1052 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1053 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1054 * @throws RundeckApiLoginException if the login failed
+1055 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1056 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1057 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1058 */
+1059publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1060 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
+1061 IllegalArgumentException {
+1062return runAdhocCommand(project,
+1063 command,
+1064 nodeFilters,
+1065 nodeThreadcount,
+1066 nodeKeepgoing,
+1067 DEFAULT_POOLING_INTERVAL,
+1068 DEFAULT_POOLING_UNIT);
+1069 }
+1070
+1071/**
+1072 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1073 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1074 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1075 * nodeFilters parameter.
+1076 *
+1077 * @param project name of the project - mandatory
+1078 * @param command to be executed - mandatory
+1079 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1080 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1081 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1082 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1083 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1084 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1085 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1086 * @throws RundeckApiLoginException if the login failed
+1087 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1088 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1089 */
+1090publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1091 Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval, TimeUnit poolingUnit)
+1092throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1093if (poolingInterval <= 0) {
+1094 poolingInterval = DEFAULT_POOLING_INTERVAL;
+1095 poolingUnit = DEFAULT_POOLING_UNIT;
+1096 }
+1097if (poolingUnit == null) {
+1098 poolingUnit = DEFAULT_POOLING_UNIT;
+1099 }
+1100
+1101RundeckExecution execution = triggerAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing);
+1102while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+1103try {
+1104 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+1105 } catch (InterruptedException e) {
+1106break;
+1107 }
+1108 execution = getExecution(execution.getId());
1109 }
-1110return executions;
+1110return execution;
1111 }
1112
-1113/**
-1114 * Get the running executions for the given project
-1115 *
-1116 * @param project name of the project - mandatory
-1117 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1118 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1119 * @throws RundeckApiLoginException if the login failed
-1120 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-1121 * @see #getRunningExecutions()
-1122 */
-1123public List<RundeckExecution> getRunningExecutions(String project) throws RundeckApiException,
-1124 RundeckApiLoginException, IllegalArgumentException {
-1125 AssertUtil.notBlank(project, "project is mandatory get all running executions !");
-1126returnnewApiCall(this).get(newApiPathBuilder("/executions/running").param("project", project),
-1127new ListParser<RundeckExecution>(newExecutionParser(),
-1128"result/executions/execution"));
-1129 }
-1130
-1131/**
-1132 * Get the executions of the given job
-1133 *
-1134 * @param jobId identifier of the job - mandatory
-1135 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1136 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1137 * @throws RundeckApiLoginException if the login failed
-1138 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1139 * @see #getJobExecutions(String, ExecutionStatus, Long, Long)
-1140 */
-1141public List<RundeckExecution> getJobExecutions(String jobId) throws RundeckApiException, RundeckApiLoginException,
-1142 IllegalArgumentException {
-1143return getJobExecutions(jobId, (ExecutionStatus) null);
-1144 }
-1145
-1146/**
-1147 * Get the executions of the given job
-1148 *
-1149 * @param jobId identifier of the job - mandatory
-1150 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-1151 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1152 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1153 * @throws RundeckApiLoginException if the login failed
-1154 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
-1155 * invalid
-1156 * @see #getJobExecutions(String, ExecutionStatus, Long, Long)
-1157 */
-1158public List<RundeckExecution> getJobExecutions(String jobId, String status) throws RundeckApiException,
-1159 RundeckApiLoginException, IllegalArgumentException {
-1160return getJobExecutions(jobId,
-1161 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)));
-1162 }
-1163
-1164/**
-1165 * Get the executions of the given job
-1166 *
-1167 * @param jobId identifier of the job - mandatory
-1168 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-1169 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1170 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1171 * @throws RundeckApiLoginException if the login failed
-1172 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1173 * @see #getJobExecutions(String, ExecutionStatus, Long, Long)
-1174 */
-1175public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status) throws RundeckApiException,
-1176 RundeckApiLoginException, IllegalArgumentException {
-1177return getJobExecutions(jobId, status, null, null);
-1178 }
-1179
-1180/**
-1181 * Get the executions of the given job
-1182 *
-1183 * @param jobId identifier of the job - mandatory
-1184 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-1185 * @param max number of results to return - optional (null for all)
-1186 * @param offset the 0-indexed offset for the first result to return - optional
-1187 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1188 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1189 * @throws RundeckApiLoginException if the login failed
-1190 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
-1191 * invalid
-1192 * @see #getJobExecutions(String, ExecutionStatus, Long, Long)
-1193 */
-1194public List<RundeckExecution> getJobExecutions(String jobId, String status, Long max, Long offset)
-1195throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-1196return getJobExecutions(jobId,
-1197 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)),
-1198 max,
-1199 offset);
-1200 }
-1201
-1202/**
-1203 * Get the executions of the given job
-1204 *
-1205 * @param jobId identifier of the job - mandatory
-1206 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-1207 * @param max number of results to return - optional (null for all)
-1208 * @param offset the 0-indexed offset for the first result to return - optional
-1209 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1210 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1211 * @throws RundeckApiLoginException if the login failed
-1212 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1213 */
-1214public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status, Long max, Long offset)
-1215throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
-1216 AssertUtil.notBlank(jobId, "jobId is mandatory to get the executions of a job !");
-1217returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/executions").param("status", status)
-1218 .param("max", max)
-1219 .param("offset", offset),
-1220new ListParser<RundeckExecution>(newExecutionParser(),
-1221"result/executions/execution"));
-1222 }
-1223
-1224/**
-1225 * Get a single execution, identified by the given ID
-1226 *
-1227 * @param executionId identifier of the execution - mandatory
-1228 * @return a {@link RundeckExecution} instance - won't be null
-1229 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
-1230 * @throws RundeckApiLoginException if the login failed
-1231 * @throws IllegalArgumentException if the executionId is null
-1232 */
-1233publicRundeckExecution getExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
-1234 IllegalArgumentException {
-1235 AssertUtil.notNull(executionId, "executionId is mandatory to get the details of an execution !");
-1236returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString()),
-1237newExecutionParser("result/executions/execution"));
-1238 }
-1239
-1240/**
-1241 * Abort an execution (identified by the given ID). The execution should be running...
-1242 *
-1243 * @param executionId identifier of the execution - mandatory
-1244 * @return a {@link RundeckAbort} instance - won't be null
-1245 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
-1246 * @throws RundeckApiLoginException if the login failed
-1247 * @throws IllegalArgumentException if the executionId is null
-1248 */
-1249publicRundeckAbort abortExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
-1250 IllegalArgumentException {
-1251 AssertUtil.notNull(executionId, "executionId is mandatory to abort an execution !");
-1252returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/abort"),
-1253newAbortParser("result/abort"));
-1254 }
-1255
-1256/*
-1257 * Nodes
-1258 */
-1259
-1260/**
-1261 * List all nodes (for all projects)
-1262 *
-1263 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-1264 * @throws RundeckApiException in case of error when calling the API
-1265 * @throws RundeckApiLoginException if the login failed
-1266 */
-1267public List<RundeckNode> getNodes() throws RundeckApiException, RundeckApiLoginException {
-1268 List<RundeckNode> nodes = new ArrayList<RundeckNode>();
-1269for (RundeckProject project : getProjects()) {
-1270 nodes.addAll(getNodes(project.getName()));
-1271 }
-1272return nodes;
-1273 }
-1274
-1275/**
-1276 * List all nodes that belongs to the given project
-1277 *
-1278 * @param project name of the project - mandatory
-1279 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-1280 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1281 * @throws RundeckApiLoginException if the login failed
-1282 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-1283 * @see #getNodes(String, Properties)
-1284 */
-1285public List<RundeckNode> getNodes(String project) throws RundeckApiException, RundeckApiLoginException,
-1286 IllegalArgumentException {
-1287return getNodes(project, null);
-1288 }
-1289
-1290/**
-1291 * List nodes that belongs to the given project
-1292 *
-1293 * @param project name of the project - mandatory
-1294 * @param nodeFilters for filtering the nodes - optional. See {@link NodeFiltersBuilder}
-1295 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-1296 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1297 * @throws RundeckApiLoginException if the login failed
-1298 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-1299 */
-1300public List<RundeckNode> getNodes(String project, Properties nodeFilters) throws RundeckApiException,
-1301 RundeckApiLoginException, IllegalArgumentException {
-1302 AssertUtil.notBlank(project, "project is mandatory to get all nodes !");
-1303returnnewApiCall(this).get(newApiPathBuilder("/resources").param("project", project)
-1304 .nodeFilters(nodeFilters),
-1305new ListParser<RundeckNode>(newNodeParser(), "project/node"));
-1306 }
-1307
-1308/**
-1309 * Get the definition of a single node
-1310 *
-1311 * @param name of the node - mandatory
-1312 * @param project name of the project - mandatory
-1313 * @return a {@link RundeckNode} instance - won't be null
-1314 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
-1315 * @throws RundeckApiLoginException if the login failed
-1316 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+1113/*
+1114 * Ad-hoc scripts
+1115 */
+1116
+1117/**
+1118 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1119 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1120 *
+1121 * @param project name of the project - mandatory
+1122 * @param scriptFilename filename of the script to be executed - mandatory
+1123 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1124 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1125 * @throws RundeckApiLoginException if the login failed
+1126 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1127 * @throws IOException if we failed to read the file
+1128 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1129 * @see #runAdhocScript(String, String)
+1130 */
+1131publicRundeckExecution triggerAdhocScript(String project, String scriptFilename) throws RundeckApiException,
+1132 RundeckApiLoginException, IllegalArgumentException, IOException {
+1133return triggerAdhocScript(project, scriptFilename, null);
+1134 }
+1135
+1136/**
+1137 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1138 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1139 *
+1140 * @param project name of the project - mandatory
+1141 * @param scriptFilename filename of the script to be executed - mandatory
+1142 * @param options of the script - optional. See {@link OptionsBuilder}.
+1143 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1144 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1145 * @throws RundeckApiLoginException if the login failed
+1146 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1147 * @throws IOException if we failed to read the file
+1148 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1149 * @see #runAdhocScript(String, String, Properties)
+1150 */
+1151publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options)
+1152throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
+1153return triggerAdhocScript(project, scriptFilename, options, null);
+1154 }
+1155
+1156/**
+1157 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1158 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1159 *
+1160 * @param project name of the project - mandatory
+1161 * @param scriptFilename filename of the script to be executed - mandatory
+1162 * @param options of the script - optional. See {@link OptionsBuilder}.
+1163 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1164 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1165 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1166 * @throws RundeckApiLoginException if the login failed
+1167 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1168 * @throws IOException if we failed to read the file
+1169 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1170 * @see #runAdhocScript(String, String, Properties, Properties)
+1171 */
+1172publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
+1173 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1174 IOException {
+1175return triggerAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
+1176 }
+1177
+1178/**
+1179 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1180 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1181 *
+1182 * @param project name of the project - mandatory
+1183 * @param scriptFilename filename of the script to be executed - mandatory
+1184 * @param options of the script - optional. See {@link OptionsBuilder}.
+1185 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1186 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1187 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1188 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1189 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1190 * @throws RundeckApiLoginException if the login failed
+1191 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1192 * @throws IOException if we failed to read the file
+1193 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1194 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1195 */
+1196publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
+1197 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1198 RundeckApiLoginException, IllegalArgumentException, IOException {
+1199 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to trigger an ad-hoc script !");
+1200 FileInputStream stream = null;
+1201try {
+1202 stream = FileUtils.openInputStream(new File(scriptFilename));
+1203return triggerAdhocScript(project, stream, options, nodeFilters, nodeThreadcount, nodeKeepgoing);
+1204 } finally {
+1205 IOUtils.closeQuietly(stream);
+1206 }
+1207 }
+1208
+1209/**
+1210 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1211 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1212 *
+1213 * @param project name of the project - mandatory
+1214 * @param script inputStream for reading the script to be executed - mandatory
+1215 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1216 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1217 * @throws RundeckApiLoginException if the login failed
+1218 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1219 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1220 * @see #runAdhocScript(String, InputStream)
+1221 */
+1222publicRundeckExecution triggerAdhocScript(String project, InputStream script) throws RundeckApiException,
+1223 RundeckApiLoginException, IllegalArgumentException {
+1224return triggerAdhocScript(project, script, null);
+1225 }
+1226
+1227/**
+1228 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1229 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1230 *
+1231 * @param project name of the project - mandatory
+1232 * @param script inputStream for reading the script to be executed - mandatory
+1233 * @param options of the script - optional. See {@link OptionsBuilder}.
+1234 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1235 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1236 * @throws RundeckApiLoginException if the login failed
+1237 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1238 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1239 * @see #runAdhocScript(String, InputStream, Properties)
+1240 */
+1241publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options)
+1242throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1243return triggerAdhocScript(project, script, options, null);
+1244 }
+1245
+1246/**
+1247 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1248 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1249 *
+1250 * @param project name of the project - mandatory
+1251 * @param script inputStream for reading the script to be executed - mandatory
+1252 * @param options of the script - optional. See {@link OptionsBuilder}.
+1253 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1254 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1255 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1256 * @throws RundeckApiLoginException if the login failed
+1257 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1258 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1259 * @see #runAdhocScript(String, InputStream, Properties, Properties)
+1260 */
+1261publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
+1262 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1263return triggerAdhocScript(project, script, options, nodeFilters, null, null);
+1264 }
+1265
+1266/**
+1267 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1268 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1269 *
+1270 * @param project name of the project - mandatory
+1271 * @param script inputStream for reading the script to be executed - mandatory
+1272 * @param options of the script - optional. See {@link OptionsBuilder}.
+1273 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1274 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1275 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1276 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1277 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1278 * @throws RundeckApiLoginException if the login failed
+1279 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1280 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1281 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1282 */
+1283publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
+1284 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1285 RundeckApiLoginException, IllegalArgumentException {
+1286 AssertUtil.notBlank(project, "project is mandatory to trigger an ad-hoc script !");
+1287 AssertUtil.notNull(script, "script is mandatory to trigger an ad-hoc script !");
+1288RundeckExecution execution = newApiCall(this).post(newApiPathBuilder("/run/script").param("project", project)
+1289 .attach("scriptFile",
+1290 script)
+1291 .param("argString",
+1292 ParametersUtil.generateArgString(options))
+1293 .param("nodeThreadcount",
+1294 nodeThreadcount)
+1295 .param("nodeKeepgoing",
+1296 nodeKeepgoing)
+1297 .nodeFilters(nodeFilters),
+1298newExecutionParser("result/execution"));
+1299// the first call just returns the ID of the execution, so we need another call to get a "real" execution
+1300return getExecution(execution.getId());
+1301 }
+1302
+1303/**
+1304 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1305 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1306 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+1307 *
+1308 * @param project name of the project - mandatory
+1309 * @param scriptFilename filename of the script to be executed - mandatory
+1310 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1311 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1312 * @throws RundeckApiLoginException if the login failed
+1313 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1314 * @throws IOException if we failed to read the file
+1315 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1316 * @see #triggerAdhocScript(String, String)1317 */
-1318publicRundeckNode getNode(String name, String project) throws RundeckApiException, RundeckApiLoginException,
-1319 IllegalArgumentException {
-1320 AssertUtil.notBlank(name, "the name of the node is mandatory to get a node !");
-1321 AssertUtil.notBlank(project, "project is mandatory to get a node !");
-1322returnnewApiCall(this).get(newApiPathBuilder("/resource/", name).param("project", project),
-1323newNodeParser("project/node"));
-1324 }
-1325
-1326/*
-1327 * System Info
-1328 */
-1329
-1330/**
-1331 * Get system informations about the RunDeck server
-1332 *
-1333 * @return a {@link RundeckSystemInfo} instance - won't be null
-1334 * @throws RundeckApiException in case of error when calling the API
-1335 * @throws RundeckApiException if the login failed
-1336 */
-1337publicRundeckSystemInfo getSystemInfo() throws RundeckApiException, RundeckApiLoginException {
-1338returnnewApiCall(this).get(newApiPathBuilder("/system/info"), newSystemInfoParser("result/system"));
-1339 }
-1340
-1341public String getUrl() {
-1342return url;
-1343 }
-1344
-1345public String getLogin() {
-1346return login;
-1347 }
-1348
-1349public String getPassword() {
-1350return password;
-1351 }
-1352
-1353 @Override
-1354public String toString() {
-1355return"RundeckClient [url=" + url + ", login=" + login + ", password=" + password + "]";
-1356 }
-1357
-1358 @Override
-1359publicint hashCode() {
-1360finalint prime = 31;
-1361int result = 1;
-1362 result = prime * result + ((login == null) ? 0 : login.hashCode());
-1363 result = prime * result + ((password == null) ? 0 : password.hashCode());
-1364 result = prime * result + ((url == null) ? 0 : url.hashCode());
-1365return result;
+1318publicRundeckExecution runAdhocScript(String project, String scriptFilename) throws RundeckApiException,
+1319 RundeckApiLoginException, IllegalArgumentException, IOException {
+1320return runAdhocScript(project, scriptFilename, null);
+1321 }
+1322
+1323/**
+1324 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1325 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1326 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+1327 * RunDeck server.
+1328 *
+1329 * @param project name of the project - mandatory
+1330 * @param scriptFilename filename of the script to be executed - mandatory
+1331 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1332 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1333 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1334 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1335 * @throws RundeckApiLoginException if the login failed
+1336 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1337 * @throws IOException if we failed to read the file
+1338 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1339 * @see #triggerAdhocScript(String, String)
+1340 */
+1341publicRundeckExecution runAdhocScript(String project, String scriptFilename, long poolingInterval,
+1342 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1343 IOException {
+1344return runAdhocScript(project, scriptFilename, null, poolingInterval, poolingUnit);
+1345 }
+1346
+1347/**
+1348 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1349 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1350 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+1351 *
+1352 * @param project name of the project - mandatory
+1353 * @param scriptFilename filename of the script to be executed - mandatory
+1354 * @param options of the script - optional. See {@link OptionsBuilder}.
+1355 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1356 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1357 * @throws RundeckApiLoginException if the login failed
+1358 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1359 * @throws IOException if we failed to read the file
+1360 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1361 * @see #triggerAdhocScript(String, String, Properties)
+1362 */
+1363publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options)
+1364throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
+1365return runAdhocScript(project, scriptFilename, options, null);
1366 }
1367
-1368 @Override
-1369publicboolean equals(Object obj) {
-1370if (this == obj)
-1371returntrue;
-1372if (obj == null)
-1373return false;
-1374if (getClass() != obj.getClass())
-1375return false;
-1376RundeckClient other = (RundeckClient) obj;
-1377if (login == null) {
-1378if (other.login != null)
-1379return false;
-1380 } elseif (!login.equals(other.login))
-1381return false;
-1382if (password == null) {
-1383if (other.password != null)
-1384return false;
-1385 } elseif (!password.equals(other.password))
-1386return false;
-1387if (url == null) {
-1388if (other.url != null)
-1389return false;
-1390 } elseif (!url.equals(other.url))
-1391return false;
-1392returntrue;
-1393 }
-1394
-1395 }
+1368/**
+1369 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1370 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1371 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+1372 * RunDeck server.
+1373 *
+1374 * @param project name of the project - mandatory
+1375 * @param scriptFilename filename of the script to be executed - mandatory
+1376 * @param options of the script - optional. See {@link OptionsBuilder}.
+1377 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1378 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1379 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1380 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1381 * @throws RundeckApiLoginException if the login failed
+1382 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1383 * @throws IOException if we failed to read the file
+1384 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1385 * @see #triggerAdhocScript(String, String, Properties)
+1386 */
+1387publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+1388long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+1389 IllegalArgumentException, IOException {
+1390return runAdhocScript(project, scriptFilename, options, null, poolingInterval, poolingUnit);
+1391 }
+1392
+1393/**
+1394 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1395 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1396 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1397 *
+1398 * @param project name of the project - mandatory
+1399 * @param scriptFilename filename of the script to be executed - mandatory
+1400 * @param options of the script - optional. See {@link OptionsBuilder}.
+1401 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1402 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1403 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1404 * @throws RundeckApiLoginException if the login failed
+1405 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1406 * @throws IOException if we failed to read the file
+1407 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1408 * @see #triggerAdhocScript(String, String, Properties, Properties)
+1409 */
+1410publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+1411 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1412 IOException {
+1413return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
+1414 }
+1415
+1416/**
+1417 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1418 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1419 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+1420 * parameter.
+1421 *
+1422 * @param project name of the project - mandatory
+1423 * @param scriptFilename filename of the script to be executed - mandatory
+1424 * @param options of the script - optional. See {@link OptionsBuilder}.
+1425 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1426 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1427 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1428 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1429 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1430 * @throws RundeckApiLoginException if the login failed
+1431 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1432 * @throws IOException if we failed to read the file
+1433 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1434 * @see #triggerAdhocScript(String, String, Properties, Properties)
+1435 */
+1436publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+1437 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
+1438 RundeckApiLoginException, IllegalArgumentException, IOException {
+1439return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null, poolingInterval, poolingUnit);
+1440 }
+1441
+1442/**
+1443 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1444 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1445 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1446 *
+1447 * @param project name of the project - mandatory
+1448 * @param scriptFilename filename of the script to be executed - mandatory
+1449 * @param options of the script - optional. See {@link OptionsBuilder}.
+1450 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1451 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1452 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1453 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1454 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1455 * @throws RundeckApiLoginException if the login failed
+1456 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1457 * @throws IOException if we failed to read the file
+1458 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1459 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1460 */
+1461publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+1462 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1463 RundeckApiLoginException, IllegalArgumentException, IOException {
+1464return runAdhocScript(project,
+1465 scriptFilename,
+1466 options,
+1467 nodeFilters,
+1468 nodeThreadcount,
+1469 nodeKeepgoing,
+1470 DEFAULT_POOLING_INTERVAL,
+1471 DEFAULT_POOLING_UNIT);
+1472 }
+1473
+1474/**
+1475 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1476 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1477 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+1478 * parameter.
+1479 *
+1480 * @param project name of the project - mandatory
+1481 * @param scriptFilename filename of the script to be executed - mandatory
+1482 * @param options of the script - optional. See {@link OptionsBuilder}.
+1483 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1484 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1485 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1486 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1487 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1488 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1489 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1490 * @throws RundeckApiLoginException if the login failed
+1491 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1492 * @throws IOException if we failed to read the file
+1493 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1494 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1495 */
+1496publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+1497 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
+1498 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1499 IOException {
+1500 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to run an ad-hoc script !");
+1501 FileInputStream stream = null;
+1502try {
+1503 stream = FileUtils.openInputStream(new File(scriptFilename));
+1504return runAdhocScript(project,
+1505 stream,
+1506 options,
+1507 nodeFilters,
+1508 nodeThreadcount,
+1509 nodeKeepgoing,
+1510 poolingInterval,
+1511 poolingUnit);
+1512 } finally {
+1513 IOUtils.closeQuietly(stream);
+1514 }
+1515 }
+1516
+1517/**
+1518 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1519 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1520 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+1521 *
+1522 * @param project name of the project - mandatory
+1523 * @param script inputStream for reading the script to be executed - mandatory
+1524 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1525 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1526 * @throws RundeckApiLoginException if the login failed
+1527 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1528 * @throws IOException if we failed to read the file
+1529 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1530 * @see #triggerAdhocScript(String, InputStream)
+1531 */
+1532publicRundeckExecution runAdhocScript(String project, InputStream script) throws RundeckApiException,
+1533 RundeckApiLoginException, IllegalArgumentException, IOException {
+1534return runAdhocScript(project, script, null);
+1535 }
+1536
+1537/**
+1538 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1539 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1540 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+1541 * RunDeck server.
+1542 *
+1543 * @param project name of the project - mandatory
+1544 * @param script inputStream for reading the script to be executed - mandatory
+1545 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1546 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1547 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1548 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1549 * @throws RundeckApiLoginException if the login failed
+1550 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1551 * @throws IOException if we failed to read the file
+1552 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1553 * @see #triggerAdhocScript(String, InputStream)
+1554 */
+1555publicRundeckExecution runAdhocScript(String project, InputStream script, long poolingInterval,
+1556 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1557 IOException {
+1558return runAdhocScript(project, script, null, poolingInterval, poolingUnit);
+1559 }
+1560
+1561/**
+1562 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1563 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1564 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+1565 *
+1566 * @param project name of the project - mandatory
+1567 * @param script inputStream for reading the script to be executed - mandatory
+1568 * @param options of the script - optional. See {@link OptionsBuilder}.
+1569 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1570 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1571 * @throws RundeckApiLoginException if the login failed
+1572 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1573 * @throws IOException if we failed to read the file
+1574 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1575 * @see #triggerAdhocScript(String, InputStream, Properties)
+1576 */
+1577publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options)
+1578throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException, IOException {
+1579return runAdhocScript(project, script, options, null);
+1580 }
+1581
+1582/**
+1583 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1584 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1585 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+1586 * RunDeck server.
+1587 *
+1588 * @param project name of the project - mandatory
+1589 * @param script inputStream for reading the script to be executed - mandatory
+1590 * @param options of the script - optional. See {@link OptionsBuilder}.
+1591 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1592 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1593 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1594 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1595 * @throws RundeckApiLoginException if the login failed
+1596 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1597 * @throws IOException if we failed to read the file
+1598 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1599 * @see #triggerAdhocScript(String, InputStream, Properties)
+1600 */
+1601publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+1602long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+1603 IllegalArgumentException, IOException {
+1604return runAdhocScript(project, script, options, null, poolingInterval, poolingUnit);
+1605 }
+1606
+1607/**
+1608 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1609 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1610 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1611 *
+1612 * @param project name of the project - mandatory
+1613 * @param script inputStream for reading the script to be executed - mandatory
+1614 * @param options of the script - optional. See {@link OptionsBuilder}.
+1615 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1616 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1617 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1618 * @throws RundeckApiLoginException if the login failed
+1619 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1620 * @throws IOException if we failed to read the file
+1621 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1622 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
+1623 */
+1624publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+1625 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException,
+1626 IOException {
+1627return runAdhocScript(project, script, options, nodeFilters, null, null);
+1628 }
+1629
+1630/**
+1631 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1632 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1633 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+1634 * parameter.
+1635 *
+1636 * @param project name of the project - mandatory
+1637 * @param script inputStream for reading the script to be executed - mandatory
+1638 * @param options of the script - optional. See {@link OptionsBuilder}.
+1639 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1640 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1641 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1642 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1643 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1644 * @throws RundeckApiLoginException if the login failed
+1645 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1646 * @throws IOException if we failed to read the file
+1647 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1648 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
+1649 */
+1650publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+1651 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
+1652 RundeckApiLoginException, IllegalArgumentException, IOException {
+1653return runAdhocScript(project, script, options, nodeFilters, null, null, poolingInterval, poolingUnit);
+1654 }
+1655
+1656/**
+1657 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1658 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1659 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1660 *
+1661 * @param project name of the project - mandatory
+1662 * @param script inputStream for reading the script to be executed - mandatory
+1663 * @param options of the script - optional. See {@link OptionsBuilder}.
+1664 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1665 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1666 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1667 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1668 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1669 * @throws RundeckApiLoginException if the login failed
+1670 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1671 * @throws IOException if we failed to read the file
+1672 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1673 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1674 */
+1675publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+1676 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1677 RundeckApiLoginException, IllegalArgumentException, IOException {
+1678return runAdhocScript(project,
+1679 script,
+1680 options,
+1681 nodeFilters,
+1682 nodeThreadcount,
+1683 nodeKeepgoing,
+1684 DEFAULT_POOLING_INTERVAL,
+1685 DEFAULT_POOLING_UNIT);
+1686 }
+1687
+1688/**
+1689 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1690 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1691 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+1692 * parameter.
+1693 *
+1694 * @param project name of the project - mandatory
+1695 * @param script inputStream for reading the script to be executed - mandatory
+1696 * @param options of the script - optional. See {@link OptionsBuilder}.
+1697 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+1698 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1699 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1700 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1701 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1702 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1703 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1704 * @throws RundeckApiLoginException if the login failed
+1705 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1706 * @throws IOException if we failed to read the file
+1707 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1708 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1709 */
+1710publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+1711 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
+1712 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1713if (poolingInterval <= 0) {
+1714 poolingInterval = DEFAULT_POOLING_INTERVAL;
+1715 poolingUnit = DEFAULT_POOLING_UNIT;
+1716 }
+1717if (poolingUnit == null) {
+1718 poolingUnit = DEFAULT_POOLING_UNIT;
+1719 }
+1720
+1721RundeckExecution execution = triggerAdhocScript(project,
+1722 script,
+1723 options,
+1724 nodeFilters,
+1725 nodeThreadcount,
+1726 nodeKeepgoing);
+1727while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+1728try {
+1729 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+1730 } catch (InterruptedException e) {
+1731break;
+1732 }
+1733 execution = getExecution(execution.getId());
+1734 }
+1735return execution;
+1736 }
+1737
+1738/*
+1739 * Executions
+1740 */
+1741
+1742/**
+1743 * Get all running executions (for all projects)
+1744 *
+1745 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1746 * @throws RundeckApiException in case of error when calling the API
+1747 * @throws RundeckApiLoginException if the login failed
+1748 * @see #getRunningExecutions(String)
+1749 */
+1750public List<RundeckExecution> getRunningExecutions() throws RundeckApiException, RundeckApiLoginException {
+1751 List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
+1752for (RundeckProject project : getProjects()) {
+1753 executions.addAll(getRunningExecutions(project.getName()));
+1754 }
+1755return executions;
+1756 }
+1757
+1758/**
+1759 * Get the running executions for the given project
+1760 *
+1761 * @param project name of the project - mandatory
+1762 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1763 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1764 * @throws RundeckApiLoginException if the login failed
+1765 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1766 * @see #getRunningExecutions()
+1767 */
+1768public List<RundeckExecution> getRunningExecutions(String project) throws RundeckApiException,
+1769 RundeckApiLoginException, IllegalArgumentException {
+1770 AssertUtil.notBlank(project, "project is mandatory get all running executions !");
+1771returnnewApiCall(this).get(newApiPathBuilder("/executions/running").param("project", project),
+1772new ListParser<RundeckExecution>(newExecutionParser(),
+1773"result/executions/execution"));
+1774 }
+1775
+1776/**
+1777 * Get the executions of the given job
+1778 *
+1779 * @param jobId identifier of the job - mandatory
+1780 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1781 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1782 * @throws RundeckApiLoginException if the login failed
+1783 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1784 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+1785 */
+1786public List<RundeckExecution> getJobExecutions(String jobId) throws RundeckApiException, RundeckApiLoginException,
+1787 IllegalArgumentException {
+1788return getJobExecutions(jobId, (ExecutionStatus) null);
+1789 }
+1790
+1791/**
+1792 * Get the executions of the given job
+1793 *
+1794 * @param jobId identifier of the job - mandatory
+1795 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+1796 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1797 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1798 * @throws RundeckApiLoginException if the login failed
+1799 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
+1800 * invalid
+1801 * @see #getJobExecutions(String, String, Long, Long)
+1802 */
+1803public List<RundeckExecution> getJobExecutions(String jobId, String status) throws RundeckApiException,
+1804 RundeckApiLoginException, IllegalArgumentException {
+1805return getJobExecutions(jobId,
+1806 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)));
+1807 }
+1808
+1809/**
+1810 * Get the executions of the given job
+1811 *
+1812 * @param jobId identifier of the job - mandatory
+1813 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+1814 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1815 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1816 * @throws RundeckApiLoginException if the login failed
+1817 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1818 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+1819 */
+1820public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status) throws RundeckApiException,
+1821 RundeckApiLoginException, IllegalArgumentException {
+1822return getJobExecutions(jobId, status, null, null);
+1823 }
+1824
+1825/**
+1826 * Get the executions of the given job
+1827 *
+1828 * @param jobId identifier of the job - mandatory
+1829 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+1830 * @param max number of results to return - optional (null for all)
+1831 * @param offset the 0-indexed offset for the first result to return - optional
+1832 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1833 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1834 * @throws RundeckApiLoginException if the login failed
+1835 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
+1836 * invalid
+1837 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+1838 */
+1839public List<RundeckExecution> getJobExecutions(String jobId, String status, Long max, Long offset)
+1840throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1841return getJobExecutions(jobId,
+1842 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)),
+1843 max,
+1844 offset);
+1845 }
+1846
+1847/**
+1848 * Get the executions of the given job
+1849 *
+1850 * @param jobId identifier of the job - mandatory
+1851 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+1852 * @param max number of results to return - optional (null for all)
+1853 * @param offset the 0-indexed offset for the first result to return - optional
+1854 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+1855 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1856 * @throws RundeckApiLoginException if the login failed
+1857 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1858 */
+1859public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status, Long max, Long offset)
+1860throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1861 AssertUtil.notBlank(jobId, "jobId is mandatory to get the executions of a job !");
+1862returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/executions").param("status", status)
+1863 .param("max", max)
+1864 .param("offset", offset),
+1865new ListParser<RundeckExecution>(newExecutionParser(),
+1866"result/executions/execution"));
+1867 }
+1868
+1869/**
+1870 * Get a single execution, identified by the given ID
+1871 *
+1872 * @param executionId identifier of the execution - mandatory
+1873 * @return a {@link RundeckExecution} instance - won't be null
+1874 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
+1875 * @throws RundeckApiLoginException if the login failed
+1876 * @throws IllegalArgumentException if the executionId is null
+1877 */
+1878publicRundeckExecution getExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
+1879 IllegalArgumentException {
+1880 AssertUtil.notNull(executionId, "executionId is mandatory to get the details of an execution !");
+1881returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString()),
+1882newExecutionParser("result/executions/execution"));
+1883 }
+1884
+1885/**
+1886 * Abort an execution (identified by the given ID). The execution should be running...
+1887 *
+1888 * @param executionId identifier of the execution - mandatory
+1889 * @return a {@link RundeckAbort} instance - won't be null
+1890 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
+1891 * @throws RundeckApiLoginException if the login failed
+1892 * @throws IllegalArgumentException if the executionId is null
+1893 */
+1894publicRundeckAbort abortExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
+1895 IllegalArgumentException {
+1896 AssertUtil.notNull(executionId, "executionId is mandatory to abort an execution !");
+1897returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/abort"),
+1898newAbortParser("result/abort"));
+1899 }
+1900
+1901/*
+1902 * History
+1903 */
+1904
+1905/**
+1906 * Get the (events) history for the given project
+1907 *
+1908 * @param project name of the project - mandatory
+1909 * @return a {@link RundeckHistory} instance - won't be null
+1910 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1911 * @throws RundeckApiLoginException if the login failed
+1912 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1913 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+1914 */
+1915publicRundeckHistory getHistory(String project) throws RundeckApiException, RundeckApiLoginException,
+1916 IllegalArgumentException {
+1917return getHistory(project, null, null, null, null, null, null, null, null);
+1918 }
+1919
+1920/**
+1921 * Get the (events) history for the given project
+1922 *
+1923 * @param project name of the project - mandatory
+1924 * @param max number of results to return - optional (default to 20)
+1925 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+1926 * @return a {@link RundeckHistory} instance - won't be null
+1927 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1928 * @throws RundeckApiLoginException if the login failed
+1929 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1930 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+1931 */
+1932publicRundeckHistory getHistory(String project, Long max, Long offset) throws RundeckApiException,
+1933 RundeckApiLoginException, IllegalArgumentException {
+1934return getHistory(project, null, null, null, null, null, null, max, offset);
+1935 }
+1936
+1937/**
+1938 * Get the (events) history for the given project
+1939 *
+1940 * @param project name of the project - mandatory
+1941 * @param jobId include only events matching the given job ID - optional
+1942 * @param reportId include only events matching the given report ID - optional
+1943 * @param user include only events created by the given user - optional
+1944 * @return a {@link RundeckHistory} instance - won't be null
+1945 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1946 * @throws RundeckApiLoginException if the login failed
+1947 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1948 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+1949 */
+1950publicRundeckHistory getHistory(String project, String jobId, String reportId, String user)
+1951throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1952return getHistory(project, jobId, reportId, user, null, null, null, null, null);
+1953 }
+1954
+1955/**
+1956 * Get the (events) history for the given project
+1957 *
+1958 * @param project name of the project - mandatory
+1959 * @param jobId include only events matching the given job ID - optional
+1960 * @param reportId include only events matching the given report ID - optional
+1961 * @param user include only events created by the given user - optional
+1962 * @param max number of results to return - optional (default to 20)
+1963 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+1964 * @return a {@link RundeckHistory} instance - won't be null
+1965 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1966 * @throws RundeckApiLoginException if the login failed
+1967 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1968 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+1969 */
+1970publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, Long max, Long offset)
+1971throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+1972return getHistory(project, jobId, reportId, user, null, null, null, max, offset);
+1973 }
+1974
+1975/**
+1976 * Get the (events) history for the given project
+1977 *
+1978 * @param project name of the project - mandatory
+1979 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+1980 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+1981 * weeks), "5d" (= last 5 days), etc. Optional.
+1982 * @return a {@link RundeckHistory} instance - won't be null
+1983 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1984 * @throws RundeckApiLoginException if the login failed
+1985 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1986 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+1987 */
+1988publicRundeckHistory getHistory(String project, String recent) throws RundeckApiException,
+1989 RundeckApiLoginException, IllegalArgumentException {
+1990return getHistory(project, null, null, null, recent, null, null, null, null);
+1991 }
+1992
+1993/**
+1994 * Get the (events) history for the given project
+1995 *
+1996 * @param project name of the project - mandatory
+1997 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+1998 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+1999 * weeks), "5d" (= last 5 days), etc. Optional.
+2000 * @param max number of results to return - optional (default to 20)
+2001 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2002 * @return a {@link RundeckHistory} instance - won't be null
+2003 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2004 * @throws RundeckApiLoginException if the login failed
+2005 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2006 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2007 */
+2008publicRundeckHistory getHistory(String project, String recent, Long max, Long offset) throws RundeckApiException,
+2009 RundeckApiLoginException, IllegalArgumentException {
+2010return getHistory(project, null, null, null, recent, null, null, max, offset);
+2011 }
+2012
+2013/**
+2014 * Get the (events) history for the given project
+2015 *
+2016 * @param project name of the project - mandatory
+2017 * @param begin date for the earlier events to retrieve - optional
+2018 * @param end date for the latest events to retrieve - optional
+2019 * @return a {@link RundeckHistory} instance - won't be null
+2020 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2021 * @throws RundeckApiLoginException if the login failed
+2022 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2023 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2024 */
+2025publicRundeckHistory getHistory(String project, Date begin, Date end) throws RundeckApiException,
+2026 RundeckApiLoginException, IllegalArgumentException {
+2027return getHistory(project, null, null, null, null, begin, end, null, null);
+2028 }
+2029
+2030/**
+2031 * Get the (events) history for the given project
+2032 *
+2033 * @param project name of the project - mandatory
+2034 * @param begin date for the earlier events to retrieve - optional
+2035 * @param end date for the latest events to retrieve - optional
+2036 * @param max number of results to return - optional (default to 20)
+2037 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2038 * @return a {@link RundeckHistory} instance - won't be null
+2039 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2040 * @throws RundeckApiLoginException if the login failed
+2041 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2042 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2043 */
+2044publicRundeckHistory getHistory(String project, Date begin, Date end, Long max, Long offset)
+2045throws RundeckApiException, RundeckApiLoginException, IllegalArgumentException {
+2046return getHistory(project, null, null, null, null, begin, end, max, offset);
+2047 }
+2048
+2049/**
+2050 * Get the (events) history for the given project
+2051 *
+2052 * @param project name of the project - mandatory
+2053 * @param jobId include only events matching the given job ID - optional
+2054 * @param reportId include only events matching the given report ID - optional
+2055 * @param user include only events created by the given user - optional
+2056 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+2057 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+2058 * weeks), "5d" (= last 5 days), etc. Optional.
+2059 * @param begin date for the earlier events to retrieve - optional
+2060 * @param end date for the latest events to retrieve - optional
+2061 * @param max number of results to return - optional (default to 20)
+2062 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2063 * @return a {@link RundeckHistory} instance - won't be null
+2064 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2065 * @throws RundeckApiLoginException if the login failed
+2066 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2067 */
+2068publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, String recent,
+2069 Date begin, Date end, Long max, Long offset) throws RundeckApiException, RundeckApiLoginException,
+2070 IllegalArgumentException {
+2071 AssertUtil.notBlank(project, "project is mandatory to get the history !");
+2072returnnewApiCall(this).get(newApiPathBuilder("/history").param("project", project)
+2073 .param("jobIdFilter", jobId)
+2074 .param("reportIdFilter", reportId)
+2075 .param("userFilter", user)
+2076 .param("recentFilter", recent)
+2077 .param("begin", begin)
+2078 .param("end", end)
+2079 .param("max", max)
+2080 .param("offset", offset),
+2081newHistoryParser("result/events"));
+2082 }
+2083
+2084/*
+2085 * Nodes
+2086 */
+2087
+2088/**
+2089 * List all nodes (for all projects)
+2090 *
+2091 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+2092 * @throws RundeckApiException in case of error when calling the API
+2093 * @throws RundeckApiLoginException if the login failed
+2094 */
+2095public List<RundeckNode> getNodes() throws RundeckApiException, RundeckApiLoginException {
+2096 List<RundeckNode> nodes = new ArrayList<RundeckNode>();
+2097for (RundeckProject project : getProjects()) {
+2098 nodes.addAll(getNodes(project.getName()));
+2099 }
+2100return nodes;
+2101 }
+2102
+2103/**
+2104 * List all nodes that belongs to the given project
+2105 *
+2106 * @param project name of the project - mandatory
+2107 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+2108 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2109 * @throws RundeckApiLoginException if the login failed
+2110 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2111 * @see #getNodes(String, Properties)
+2112 */
+2113public List<RundeckNode> getNodes(String project) throws RundeckApiException, RundeckApiLoginException,
+2114 IllegalArgumentException {
+2115return getNodes(project, null);
+2116 }
+2117
+2118/**
+2119 * List nodes that belongs to the given project
+2120 *
+2121 * @param project name of the project - mandatory
+2122 * @param nodeFilters for filtering the nodes - optional. See {@link NodeFiltersBuilder}
+2123 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+2124 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2125 * @throws RundeckApiLoginException if the login failed
+2126 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2127 */
+2128public List<RundeckNode> getNodes(String project, Properties nodeFilters) throws RundeckApiException,
+2129 RundeckApiLoginException, IllegalArgumentException {
+2130 AssertUtil.notBlank(project, "project is mandatory to get all nodes !");
+2131returnnewApiCall(this).get(newApiPathBuilder("/resources").param("project", project)
+2132 .nodeFilters(nodeFilters),
+2133new ListParser<RundeckNode>(newNodeParser(), "project/node"));
+2134 }
+2135
+2136/**
+2137 * Get the definition of a single node
+2138 *
+2139 * @param name of the node - mandatory
+2140 * @param project name of the project - mandatory
+2141 * @return a {@link RundeckNode} instance - won't be null
+2142 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
+2143 * @throws RundeckApiLoginException if the login failed
+2144 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+2145 */
+2146publicRundeckNode getNode(String name, String project) throws RundeckApiException, RundeckApiLoginException,
+2147 IllegalArgumentException {
+2148 AssertUtil.notBlank(name, "the name of the node is mandatory to get a node !");
+2149 AssertUtil.notBlank(project, "project is mandatory to get a node !");
+2150returnnewApiCall(this).get(newApiPathBuilder("/resource/", name).param("project", project),
+2151newNodeParser("project/node"));
+2152 }
+2153
+2154/*
+2155 * System Info
+2156 */
+2157
+2158/**
+2159 * Get system informations about the RunDeck server
+2160 *
+2161 * @return a {@link RundeckSystemInfo} instance - won't be null
+2162 * @throws RundeckApiException in case of error when calling the API
+2163 * @throws RundeckApiException if the login failed
+2164 */
+2165publicRundeckSystemInfo getSystemInfo() throws RundeckApiException, RundeckApiLoginException {
+2166returnnewApiCall(this).get(newApiPathBuilder("/system/info"), newSystemInfoParser("result/system"));
+2167 }
+2168
+2169/**
+2170 * @return the URL of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
+2171 */
+2172public String getUrl() {
+2173return url;
+2174 }
+2175
+2176/**
+2177 * @return the login used for authentication on the RunDeck instance
+2178 */
+2179public String getLogin() {
+2180return login;
+2181 }
+2182
+2183/**
+2184 * @return the password used for authentication on the RunDeck instance
+2185 */
+2186public String getPassword() {
+2187return password;
+2188 }
+2189
+2190 @Override
+2191public String toString() {
+2192return"RundeckClient " + API_VERSION + " [" + url + "] (credentials=" + login + "|" + password + ")";
+2193 }
+2194
+2195 @Override
+2196publicint hashCode() {
+2197finalint prime = 31;
+2198int result = 1;
+2199 result = prime * result + ((login == null) ? 0 : login.hashCode());
+2200 result = prime * result + ((password == null) ? 0 : password.hashCode());
+2201 result = prime * result + ((url == null) ? 0 : url.hashCode());
+2202return result;
+2203 }
+2204
+2205 @Override
+2206publicboolean equals(Object obj) {
+2207if (this == obj)
+2208returntrue;
+2209if (obj == null)
+2210return false;
+2211if (getClass() != obj.getClass())
+2212return false;
+2213RundeckClient other = (RundeckClient) obj;
+2214if (login == null) {
+2215if (other.login != null)
+2216return false;
+2217 } elseif (!login.equals(other.login))
+2218return false;
+2219if (password == null) {
+2220if (other.password != null)
+2221return false;
+2222 } elseif (!password.equals(other.password))
+2223return false;
+2224if (url == null) {
+2225if (other.url != null)
+2226return false;
+2227 } elseif (!url.equals(other.url))
+2228return false;
+2229returntrue;
+2230 }
+2231
+2232 }
diff --git a/xref/org/rundeck/api/domain/RundeckEvent.html b/xref/org/rundeck/api/domain/RundeckEvent.html
new file mode 100644
index 0000000..cde27a6
--- /dev/null
+++ b/xref/org/rundeck/api/domain/RundeckEvent.html
@@ -0,0 +1,386 @@
+
+
+
+
+RundeckEvent xref
+
+
+
+
+
+1/*
+2 * Copyright 2011 Vincent Behar
+3 *
+4 * Licensed under the Apache License, Version 2.0 (the "License");
+5 * you may not use this file except in compliance with the License.
+6 * You may obtain a copy of the License at
+7 *
+8 * http://www.apache.org/licenses/LICENSE-2.0
+9 *
+10 * Unless required by applicable law or agreed to in writing, software
+11 * distributed under the License is distributed on an "AS IS" BASIS,
+12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+13 * See the License for the specific language governing permissions and
+14 * limitations under the License.
+15 */
+16package org.rundeck.api.parser;
+17
+18import java.util.List;
+19import org.dom4j.Node;
+20import org.rundeck.api.domain.RundeckEvent;
+21import org.rundeck.api.domain.RundeckHistory;
+22
+23/**
+24 * Parser for a single {@link RundeckHistory}
+25 *
+26 * @author Vincent Behar
+27 */
+28publicclassHistoryParserimplements XmlNodeParser<RundeckHistory> {
+29
+30private String xpath;
+31
+32publicHistoryParser() {
+33super();
+34 }
+35
+36/**
+37 * @param xpath of the history element if it is not the root node
+38 */
+39publicHistoryParser(String xpath) {
+40super();
+41this.xpath = xpath;
+42 }
+43
+44 @Override
+45publicRundeckHistory parseXmlNode(Node node) {
+46 Node eventsNode = xpath != null ? node.selectSingleNode(xpath) : node;
+47
+48RundeckHistory history = newRundeckHistory();
+49
+50 history.setCount(Integer.valueOf(eventsNode.valueOf("@count")));
+51 history.setTotal(Integer.valueOf(eventsNode.valueOf("@total")));
+52 history.setMax(Integer.valueOf(eventsNode.valueOf("@max")));
+53 history.setOffset(Integer.valueOf(eventsNode.valueOf("@offset")));
+54
+55 @SuppressWarnings("unchecked")
+56 List<Node> eventNodes = eventsNode.selectNodes("event");
+57EventParser eventParser = newEventParser();
+58
+59for (Node eventNode : eventNodes) {
+60RundeckEvent event = eventParser.parseXmlNode(eventNode);
+61 history.addEvent(event);
+62 }
+63
+64return history;
+65 }
+66
+67 }
+