See the documentation of the RundeckClient class (main entry point of the API).
+=== org/rundeck/api/RunJobBuilder.html ===
+ Job run request builder
+CONSTRUCTOR: RunJobBuilder
+METHOD: build
+METHOD: builder
+METHOD: setAsUser
+METHOD: setJobId
+METHOD: setNodeFilters
+METHOD: setOptions
+
+
+=== org/rundeck/api/RunJob.html ===
+ Job run request
+METHOD: getAsUser
+ Specify a user name to run the job as, must have 'runAs' permission
+METHOD: getJobId
+ Identifier of the job - mandatory
+METHOD: getNodeFilters
+ Node filters for overriding the nodes on which the job will be executed - optional. See
+ {@link ... NodeFiltersBuilder}
+METHOD: getOptions
+ Options of the job - optional. See
+ {@link ... OptionsBuilder}
+ .
+
+
+=== org/rundeck/api/RundeckJobsImportBuilder.html ===
+ Builds a
+ {@link ... RundeckJobsImport}
+
+CONSTRUCTOR: RundeckJobsImportBuilder
+CONSTRUCTOR: RundeckJobsImportBuilder
+METHOD: build
+METHOD: builder
+ Create a new builder
+METHOD: builder
+ Create a builder initialized with an existing
+ {@link ... RundeckJobsImport}
+METHOD: setFileType
+METHOD: setJobsImportMethod
+METHOD: setProject
+METHOD: setStream
+
+
+=== org/rundeck/api/RundeckJobsImport.html ===
+ Request to import a set of Job definitions
+METHOD: getFileType
+ Return the file type
+METHOD: getImportMethod
+ Return the import behavior
+METHOD: getProject
+ Return the project name
+METHOD: getStream
+ Return the input stream
+
+
=== org/rundeck/api/RundeckClientBuilder.html ===
- Builder to create a
+ Builder to build a
{@link ... RundeckClient}
, you must specify a url, and at least one of (login, password), token, or
sessionId.
@@ -47,10 +103,53 @@ METHOD: version
=== org/rundeck/api/RundeckClient.html ===
- Main entry point to talk to a RunDeck instance.
+ Main entry point to talk to a RunDeck instance.
+
+ Deprecation Warning: These methods which take multiple arguments are deprecated in
+ favor of single argument versions, and associated Builder classes to generate them.
+ These methods will be removed in version 10 of this library:
+
+
triggerAdhocScript(...), use
+ {@link ... triggerAdhocScript(RunAdhocScript)}
+ and
+ {@link ... RunAdhocScriptBuilder}
+
+
runAdhocScript(...), use
+ {@link ... runAdhocScript(RunAdhocScript)}
+ and
+ {@link ... RunAdhocScriptBuilder}
+
+
triggerAdhocCommand(...), use
+ {@link ... triggerAdhocCommand(RunAdhocCommand)}
+ and
+ {@link ... RunAdhocCommandBuilder}
+
+
runAdhocCommand(...), use
+ {@link ... runAdhocCommand(RunAdhocCommand)}
+ and
+ {@link ... RunAdhocCommandBuilder}
+
+
triggerJob(...), use
+ {@link ... triggerJob(RunJob)}
+ and
+ {@link ... RunJobBuilder}
+
+
runJob(...), use
+ {@link ... runJob(RunJob)}
+ and
+ {@link ... RunJobBuilder}
+
+
importJobs(...), use
+ {@link ... importJobs(RundeckJobsImport)}
+ and
+ {@link ... importJobs(String, RundeckJobsImport)}
+
+
+
+
You have 2 methods for authentication : login-based or token-based. If you want to use the first, you need to provide
both a "login" and a "password". Otherwise, just provide a "token" (also called "auth-token"). See the RunDeck
- documentation for generating such a token.
+ documentation for generating such a token.
Usage :
@@ -59,15 +158,15 @@ METHOD: version
RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
// or for a token-based authentication :
RundeckClient rundeck = new RundeckClient("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
-
+
List<RundeckProject> projects = rundeck.getProjects();
-
+
RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
RundeckExecution execution = rundeck.triggerJob(job.getId(),
new OptionsBuilder().addOption("version", "1.2.0").toProperties());
-
+
List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
-
+
rundeck.exportJobsToFile("/tmp/jobs.xml", FileType.XML, "my-project");
rundeck.importJobs("/tmp/jobs.xml", FileType.XML);
@@ -76,6 +175,7 @@ FIELD: API_ENDPOINT
End-point of the API
FIELD: API_VERSION
Version of the API supported
+FIELD: JOBS_IMPORT
CONSTRUCTOR: RundeckClient
CONSTRUCTOR: RundeckClient
Instantiate a new
@@ -85,10 +185,12 @@ CONSTRUCTOR: RundeckClient
CONSTRUCTOR: RundeckClient
Instantiate a new
{@link ... RundeckClient}
- for the RunDeck instance at the given url,
+ for the RunDeck instance at the given url,
using token-based or session-based authentication. Either token or sessionID must be valid
METHOD: abortExecution
Abort an execution (identified by the given ID). The execution should be running...
+METHOD: abortExecution
+ Abort an execution (identified by the given ID). The execution should be running...
METHOD: builder
Create a builder for RundeckClient
METHOD: deleteJob
@@ -219,6 +321,10 @@ METHOD: importJobs
Import the definitions of jobs, from the given file
METHOD: importJobs
Import the definitions of jobs, from the given file, using the given behavior
+METHOD: importJobs
+ Import the definitions of jobs, from the given input stream, using the given behavior
+METHOD: importJobs
+ Import the definitions of jobs, from the given input stream, using the given behavior
METHOD: ping
Try to "ping" the RunDeck instance to see if it is alive
METHOD: runAdhocCommand
@@ -243,11 +349,25 @@ METHOD: runAdhocCommand
server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
nodeFilters parameter.
+METHOD: runAdhocCommand
+ Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
+ nodeFilters parameter.
METHOD: runAdhocCommand
Run an ad-hoc command, 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 command will not be dispatched to nodes, but be executed on the
RunDeck server.
+METHOD: runAdhocCommand
+ Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+METHOD: runAdhocCommand
+ Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
+ nodeFilters parameter.
METHOD: runAdhocScript
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
@@ -274,6 +394,11 @@ METHOD: runAdhocScript
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.
+METHOD: runAdhocScript
+ 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.
METHOD: runAdhocScript
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
@@ -320,6 +445,20 @@ METHOD: runAdhocScript
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.
+METHOD: runAdhocScript
+ 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.
+METHOD: runAdhocScript
+ Run an ad-hoc script read from a file, 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.
+METHOD: runAdhocScript
+ 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.
METHOD: runJob
Run a RunDeck job (identified by the given ID), 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
@@ -340,6 +479,18 @@ METHOD: runJob
Run a RunDeck job (identified by the given ID), 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.
+METHOD: runJob
+ Run a RunDeck job (identified by the given ID), 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.
+METHOD: runJob
+ Run a RunDeck job (identified by the given ID), 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.
+METHOD: runJob
+ Run a RunDeck job (identified by the given ID), 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.
METHOD: testAuth
Test the authentication on the RunDeck instance.
METHOD: testCredentials
@@ -353,9 +504,18 @@ METHOD: triggerAdhocCommand
METHOD: triggerAdhocCommand
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+METHOD: triggerAdhocCommand
+ Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+ The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+METHOD: triggerAdhocCommand
+ Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+ The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
METHOD: triggerAdhocScript
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.
+METHOD: triggerAdhocScript
+ 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.
METHOD: triggerAdhocScript
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.
@@ -365,9 +525,15 @@ METHOD: triggerAdhocScript
METHOD: triggerAdhocScript
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.
+METHOD: triggerAdhocScript
+ 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.
METHOD: triggerAdhocScript
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.
+METHOD: triggerAdhocScript
+ 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.
METHOD: triggerAdhocScript
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.
@@ -377,6 +543,21 @@ METHOD: triggerAdhocScript
METHOD: triggerAdhocScript
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.
+METHOD: triggerAdhocScript
+ 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.
+METHOD: triggerAdhocScript
+ 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.
+METHOD: triggerAdhocScript
+ Trigger the execution of an ad-hoc script read from a file, and return immediately (without waiting the end of
+ the execution). The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+METHOD: triggerJob
+ Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+ end of the job execution)
+METHOD: triggerJob
+ Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+ end of the job execution)
METHOD: triggerJob
Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
end of the job execution)
@@ -392,6 +573,8 @@ METHOD: triggerJob
Supported version numbers
ENUM: V5
ENUM: V6
+ENUM: V7
+ENUM: V8
METHOD: getVersionNumber
METHOD: valueOf
METHOD: values
@@ -421,6 +604,78 @@ CONSTRUCTOR: RundeckApiException.RundeckApiTokenException
CONSTRUCTOR: RundeckApiException.RundeckApiTokenException
+=== org/rundeck/api/RunAdhocScriptBuilder.html ===
+ A builder to build a
+ {@link ... RunAdhocScript}
+ , use the
+ {@link ... builder()}
+ to build a builder, then
+ {@link ... build()}
+ to build an RunAdhocScript
+CONSTRUCTOR: RunAdhocScriptBuilder
+METHOD: build
+METHOD: builder
+ Create a new builder
+METHOD: builder
+ Create a builder initialized with an existing
+ {@link ... RunAdhocScript}
+METHOD: setArgString
+METHOD: setAsUser
+METHOD: setInterpreterArgsQuoted
+METHOD: setNodeFilters
+METHOD: setNodeKeepgoing
+METHOD: setNodeThreadcount
+METHOD: setProject
+METHOD: setScript
+METHOD: setScriptInterpreter
+
+
+=== org/rundeck/api/RunAdhocScript.html ===
+ An adhoc script to be executed by Rundeck
+METHOD: getArgString
+ Arguments to the script
+METHOD: getInterpreterArgsQuoted
+ If true, quote the script filepath and args to the script interpreter.
+METHOD: getScript
+ InputStream for reading the script to be executed - mandatory
+METHOD: getScriptInterpreter
+ Command string to invoke the script with arguments
+
+
+=== org/rundeck/api/RunAdhocCommandBuilder.html ===
+ Builder for adhoc command request
+CONSTRUCTOR: RunAdhocCommandBuilder
+METHOD: build
+METHOD: builder
+METHOD: setAsUser
+METHOD: setCommand
+METHOD: setNodeFilters
+METHOD: setNodeKeepgoing
+METHOD: setNodeThreadcount
+METHOD: setProject
+
+
+=== org/rundeck/api/RunAdhocCommand.html ===
+ A command to execute
+METHOD: getCommand
+ Command to executed
+
+
+=== org/rundeck/api/RunAdhoc.html ===
+ Super interface for adhoc executions
+METHOD: getAsUser
+ Specify a user name to run the job as, must have 'runAs' permission
+METHOD: getNodeFilters
+ Filters for selecting nodes on which the command will be executed. See
+ {@link ... NodeFiltersBuilder}
+METHOD: getNodeKeepgoing
+ if true, continue executing on other nodes even if some fail - optional
+METHOD: getNodeThreadcount
+ Thread count to use (for parallelizing when running on multiple nodes) - optional
+METHOD: getProject
+ Project name, required
+
+
=== org/rundeck/api/OptionsBuilder.html ===
Builder for job options
CONSTRUCTOR: OptionsBuilder
@@ -485,6 +740,19 @@ METHOD: valueOf
METHOD: values
+=== org/rundeck/api/DefaultJobsImport.html ===
+ $INTERFACE is ... User: greg Date: 8/6/13 Time: 10:18 AM
+CONSTRUCTOR: DefaultJobsImport
+METHOD: getFileType
+METHOD: getImportMethod
+METHOD: getProject
+METHOD: getStream
+METHOD: setFileType
+METHOD: setImportMethod
+METHOD: setProject
+METHOD: setStream
+
+
=== org/rundeck/api/domain/RundeckSystemInfo.html ===
Represents the RunDeck system info
CONSTRUCTOR: RundeckSystemInfo
@@ -1019,7 +1287,7 @@ METHOD: parseXmlNode
=== org/rundeck/api/query/ExecutionQuery.html ===
- ExecutionQuery contains the query parameters for the /executions api, create one with the
+ ExecutionQuery contains the query parameters for the /executions api, build one with the
{@link ... ExecutionQuery.Builder}
class, e.g.
using the
diff --git a/apidocs/reference/classes.html b/apidocs/reference/classes.html
index 13a3fd5..8e636a0 100644
--- a/apidocs/reference/classes.html
+++ b/apidocs/reference/classes.html
@@ -253,6 +253,12 @@
+ Deprecation Warning: These methods which take multiple arguments are deprecated in
+ favor of single argument versions, and associated Builder classes to generate them.
+ These methods will be removed in version 10 of this library:
+
You have 2 methods for authentication : login-based or token-based. If you want to use the first, you need to provide
both a "login" and a "password". Otherwise, just provide a "token" (also called "auth-token"). See the RunDeck
- documentation for generating such a token.
+ documentation for generating such a token.
This constructor is deprecated.
- Use the builder RundeckClientBuilder
+ Use the builder RundeckClientBuilder, this method will not be public in version 10 of this library.
Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
end of the job execution)
@@ -2852,6 +3581,45 @@ From class
+
+
+
+
+
+ public
+ static
+ final
+ String
+
+ JOBS_IMPORT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Constant Value:
+
+
+ "/jobs/import"
+
+
+
+
+
+
+
+
+
@@ -2990,10 +3758,10 @@ From class
- This constructor is deprecated. Use the builder RundeckClientBuilder
+ This constructor is deprecated. Use the builder RundeckClientBuilder, this method will not be public in version 10 of this library.
-
Instantiate a new RundeckClient for the RunDeck instance at the given url,
+
Instantiate a new RundeckClient for the RunDeck instance at the given url,
using token-based or session-based authentication. Either token or sessionID must be valid
+
+ This method is deprecated. use runAdhocCommand(RunAdhocCommand), this method will
+ be removed in version 10 of this library
+
+
Run an ad-hoc command, 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 command will not be dispatched to nodes, but be executed on the RunDeck server.
@@ -7883,7 +8931,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocCommand(RunAdhocCommand), this method will
+ be removed in version 10 of this library
+
+
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the nodeFilters parameter.
@@ -7963,7 +9017,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocCommand(RunAdhocCommand), this method will
+ be removed in version 10 of this library
+
+
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the nodeFilters parameter.
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
+ nodeFilters parameter.
+
+
Parameters
+
+
+
project
+
name of the project - mandatory
+
+
+
command
+
to be executed - mandatory
+
+
+
nodeFilters
+
for selecting nodes on which the command will be executed. See NodeFiltersBuilder
+
+
+
nodeThreadcount
+
thread count to use (for parallelizing when running on multiple nodes) - optional
+
+
+
nodeKeepgoing
+
if true, continue executing on other nodes even if some fail - optional
+
+
+
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
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
@@ -8148,7 +9317,13 @@ From class
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
@@ -8237,7 +9412,13 @@ From class
Run an ad-hoc command, 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 command will not be dispatched to nodes, but be executed on the
@@ -8298,6 +9479,159 @@ From class
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the nodeFilters parameter.
Run an ad-hoc command, 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 command will be dispatched to nodes, accordingly to the
+ nodeFilters parameter.
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -8402,7 +9742,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -8486,7 +9832,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -8574,7 +9926,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
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 (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
@@ -8775,7 +10250,13 @@ From class
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
@@ -8872,7 +10353,13 @@ From class
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
@@ -8965,7 +10452,13 @@ From class
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
@@ -9054,7 +10547,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -9134,7 +10633,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -9218,7 +10723,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
@@ -9306,7 +10817,13 @@ From class
-
+
+
+
+ This method is deprecated. use runAdhocScript(RunAdhocScript), this method will be
+ removed in version 10 of this library
+
+
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.
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
@@ -9507,7 +11030,13 @@ From class
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
@@ -9604,7 +11133,13 @@ From class
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
@@ -9697,7 +11232,13 @@ From class
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
@@ -9762,6 +11303,256 @@ From class
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.
Run an ad-hoc script read from a file, 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.
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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Run a RunDeck job (identified by the given ID), 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.
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
The command will not be dispatched to nodes, but be executed on the RunDeck server.
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+ The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+
+
Parameters
+
+
+
project
+
name of the project - mandatory
+
+
+
command
+
to be executed - mandatory
+
+
+
nodeFilters
+
for selecting nodes on which the command will be executed. See NodeFiltersBuilder
+
+
+
nodeThreadcount
+
thread count to use (for parallelizing when running on multiple nodes) - optional
+
+
+
nodeKeepgoing
+
if true, continue executing on other nodes even if some fail - optional
+
+
+
asUser
+
specify a user name to run the job as, must have 'runAs' permission
+
+
+
+
+
Returns
+
a RundeckExecution instance for the newly created (and running) execution - won't be null
Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+ The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
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.
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
+
+
+
argString
+
arguments of the script - optional.
+
+
+
nodeFilters
+
for selecting nodes on which the command will be executed. See NodeFiltersBuilder
+
+
+
nodeThreadcount
+
thread count to use (for parallelizing when running on multiple nodes) - optional
+
+
+
nodeKeepgoing
+
if true, continue executing on other nodes even if some fail - optional
+
+
+
+
+
Returns
+
a RundeckExecution instance for the newly created (and running) execution - won't be null
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.
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.
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.
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.
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
+
+
+
argString
+
arguments of the script - optional.
+
+
+
nodeFilters
+
for selecting nodes on which the command will be executed. See NodeFiltersBuilder
+
+
+
nodeThreadcount
+
thread count to use (for parallelizing when running on multiple nodes) - optional
+
+
+
nodeKeepgoing
+
if true, continue executing on other nodes even if some fail - optional
+
+
+
+
+
Returns
+
a RundeckExecution instance for the newly created (and running) execution - won't be null
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.
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.
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.
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.
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.
Trigger the execution of an ad-hoc script read from a file, and return immediately (without waiting the end of
+ the execution). The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
ExecutionQuery contains the query parameters for the /executions api, create one with the ExecutionQuery.Builder class, e.g.
+
ExecutionQuery contains the query parameters for the /executions api, build one with the ExecutionQuery.Builder class, e.g.
using the builder() method.
Maintenance and support of rundeck-api-java-client now primarily provided by the Rundeck project, and is now available at https://rundeck.github.com/rundeck-api-java-client
Replace unwieldy methods with many arguments with Builder based interfaces, deprecating the old methods.
+ The old methods will be removed completely in version 10 of this library. Fixes 2.
Maintenance and support of rundeck-api-java-client now primarily provided by the Rundeck project, and is now available at https://rundeck.github.com/rundeck-api-java-client
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)
xercesImpl
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)
xalan
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.
Description: There is currently no description associated with this project.
Project License: No project license is defined for this project.
junit:junit:jar:4.10 (test)
JUnit
Description: JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
- It is used by the developer who implements unit tests in Java.
Description: There is currently no description associated with this project.
Project License: No project license is defined for this project.
junit:junit:jar:4.10 (test)
JUnit
Description: JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
+ It is used by the developer who implements unit tests in Java.
Note: to add a new test, do the following:
+ 1) start a rundeck server, available at hostname "rundeck.local"
+ 2) login as test or admin user, and generate a token
+ 3) add the test token as a new TEST_TOKEN_X, and use that in your test
+ 4) run 'mvn test', and commit the new yml file generated at src/test/resources/betamax/tapes
Note: to add a new test, do the following:
+ 1) start a rundeck server, available at hostname "rundeck.local"
+ 2) login as test or admin user, and generate a token
+ 3) add the test token as a new TEST_TOKEN_X, and use that in your test
+ 4) run 'mvn test', and commit the new yml file generated at src/test/resources/betamax/tapes
+
+
See Also
+
createClient(String)
+
+
@@ -985,6 +1454,84 @@ From class
+
+
+
+
+
+ public
+ static
+ final
+ String
+
+ TEST_TOKEN_3
+
+
+
+
diff --git a/xref/org/rundeck/api/RundeckClient.html b/xref/org/rundeck/api/RundeckClient.html
index 0940e04..3088278 100644
--- a/xref/org/rundeck/api/RundeckClient.html
+++ b/xref/org/rundeck/api/RundeckClient.html
@@ -50,643 +50,643 @@
40import java.util.concurrent.TimeUnit;
4142/**
-43 * Main entry point to talk to a RunDeck instance.<br>
-44 * You have 2 methods for authentication : login-based or token-based. If you want to use the first, you need to provide
-45 * both a "login" and a "password". Otherwise, just provide a "token" (also called "auth-token"). See the RunDeck
-46 * documentation for generating such a token.<br>
-47 * <br>
-48 * Usage : <br>
-49 * <code>
-50 * <pre>
-51 * // using login-based authentication :
-52 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
-53 * // or for a token-based authentication :
-54 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
-55 *
-56 * List<RundeckProject> projects = rundeck.getProjects();
-57 *
-58 * RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
-59 * RundeckExecution execution = rundeck.triggerJob(job.getId(),
-60 * new OptionsBuilder().addOption("version", "1.2.0").toProperties());
-61 *
-62 * List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
-63 *
-64 * rundeck.exportJobsToFile("/tmp/jobs.xml", FileType.XML, "my-project");
-65 * rundeck.importJobs("/tmp/jobs.xml", FileType.XML);
-66 * </pre>
-67 * </code>
-68 *
-69 * @author Vincent Behar
-70 */
-71publicclassRundeckClientimplements Serializable {
-72
-73privatestaticfinallong serialVersionUID = 1L;
-74
-75/**
-76 * Supported version numbers
-77 */
-78publicstatic enum Version {
-79 V5(5),
-80 V6(6),
-81 ;
-82
-83privateint versionNumber;
-84
-85Version(finalint i) {
-86 versionNumber = i;
-87 }
-88
-89publicint getVersionNumber() {
-90return versionNumber;
-91 }
-92 }
-93/**Version of the API supported */
-94publicstaticfinaltransientint API_VERSION = Version.V6.getVersionNumber();
-95
-96privatestaticfinal String API = "/api/";
-97
-98/** End-point of the API */
-99publicstaticfinaltransient String API_ENDPOINT = API + API_VERSION;
-100
-101/** Default value for the "pooling interval" used when running jobs/commands/scripts */
-102privatestaticfinaltransientlong DEFAULT_POOLING_INTERVAL = 5;
-103
-104/** Default unit of the "pooling interval" used when running jobs/commands/scripts */
-105privatestaticfinaltransient TimeUnit DEFAULT_POOLING_UNIT = TimeUnit.SECONDS;
+43 * Main entry point to talk to a RunDeck instance.
+44 * <p>
+45 * <em>Deprecation Warning:</em> These methods which take multiple arguments are deprecated in
+46 * favor of single argument versions, and associated Builder classes to generate them.
+47 * These methods will be removed in version 10 of this library:
+48 * <ul>
+49 * <li> triggerAdhocScript(...), use {@link #triggerAdhocScript(RunAdhocScript)} and {@link RunAdhocScriptBuilder}</li>
+50 * <li> runAdhocScript(...), use {@link #runAdhocScript(RunAdhocScript)} and {@link RunAdhocScriptBuilder}</li>
+51 * <li> triggerAdhocCommand(...), use {@link #triggerAdhocCommand(RunAdhocCommand)} and {@link
+52 * RunAdhocCommandBuilder}</li>
+53 * <li> runAdhocCommand(...), use {@link #runAdhocCommand(RunAdhocCommand)} and {@link
+54 * RunAdhocCommandBuilder}</li>
+55 * <li> triggerJob(...), use {@link #triggerJob(RunJob)} and {@link
+56 * RunJobBuilder}</li>
+57 * <li> runJob(...), use {@link #runJob(RunJob)} and {@link
+58 * RunJobBuilder}</li>
+59 * <li> importJobs(...), use {@link #importJobs(RundeckJobsImport)} and {@link #importJobs(String, RundeckJobsImport)}</li>
+60 * </ul>
+61 * </p>
+62 * <p>
+63 * You have 2 methods for authentication : login-based or token-based. If you want to use the first, you need to provide
+64 * both a "login" and a "password". Otherwise, just provide a "token" (also called "auth-token"). See the RunDeck
+65 * documentation for generating such a token.</p>
+66 * <br>
+67 * Usage : <br>
+68 * <code>
+69 * <pre>
+70 * // using login-based authentication :
+71 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
+72 * // or for a token-based authentication :
+73 * RundeckClient rundeck = new RundeckClient("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
+74 *
+75 * List<RundeckProject> projects = rundeck.getProjects();
+76 *
+77 * RundeckJob job = rundeck.findJob("my-project", "main-group/sub-group", "job-name");
+78 * RundeckExecution execution = rundeck.triggerJob(job.getId(),
+79 * new OptionsBuilder().addOption("version", "1.2.0").toProperties());
+80 *
+81 * List<RundeckExecution> runningExecutions = rundeck.getRunningExecutions("my-project");
+82 *
+83 * rundeck.exportJobsToFile("/tmp/jobs.xml", FileType.XML, "my-project");
+84 * rundeck.importJobs("/tmp/jobs.xml", FileType.XML);
+85 * </pre>
+86 * </code>
+87 *
+88 * @author Vincent Behar
+89 */
+90publicclassRundeckClientimplements Serializable {
+91
+92privatestaticfinallong serialVersionUID = 1L;
+93publicstaticfinal String JOBS_IMPORT = "/jobs/import";
+94
+95/**
+96 * Supported version numbers
+97 */
+98publicstatic enum Version {
+99 V5(5),
+100 V6(6),
+101 V7(7),
+102 V8(8),
+103 ;
+104
+105privateint versionNumber;
106
-107/** URL of the RunDeck instance ("http://localhost:4440" target="alexandria_uri">http://localhost:4440", "http://rundeck.your-compagny.com/", etc) */
-108privatefinal String url;
-109
-110privateint apiVersion = API_VERSION;
-111
-112private String token;
-113
-114private String login;
-115
-116private String password;
-117
-118private String sessionID;
+107Version(finalint i) {
+108 versionNumber = i;
+109 }
+110
+111publicint getVersionNumber() {
+112return versionNumber;
+113 }
+114 }
+115/**Version of the API supported */
+116publicstaticfinaltransientint API_VERSION = Version.V8.getVersionNumber();
+117
+118privatestaticfinal String API = "/api/";
119
-120void setToken(String token) {
-121this.token = token;
-122 }
-123
-124void setLogin(String login) {
-125this.login = login;
-126 }
-127
-128void setPassword(String password) {
-129this.password = password;
-130 }
+120/** End-point of the API */
+121publicstaticfinaltransient String API_ENDPOINT = API + API_VERSION;
+122
+123/** Default value for the "pooling interval" used when running jobs/commands/scripts */
+124privatestaticfinaltransientlong DEFAULT_POOLING_INTERVAL = 5;
+125
+126/** Default unit of the "pooling interval" used when running jobs/commands/scripts */
+127privatestaticfinaltransient TimeUnit DEFAULT_POOLING_UNIT = TimeUnit.SECONDS;
+128
+129/** URL of the RunDeck instance ("http://localhost:4440" target="alexandria_uri">http://localhost:4440", "http://rundeck.your-compagny.com/", etc) */
+130privatefinal String url;
131
-132void setSessionID(String sessionID) {
-133this.sessionID = sessionID;
-134 }
+132privateint apiVersion = API_VERSION;
+133
+134private String token;
135
-136int getApiVersion() {
-137return apiVersion;
-138 }
+136private String login;
+137
+138private String password;
139
-140void setApiVersion(int apiVersion) {
-141this.apiVersion = apiVersion;
-142 }
-143
-144void setApiVersion(Version apiVersion) {
-145this.apiVersion = apiVersion.getVersionNumber();
-146 }
-147
-148 String getApiEndpoint() {
-149return API + getApiVersion();
-150 }
-151
-152/**
-153 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url, using login-based
-154 * authentication.
-155 *
-156 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
-157 * @param login to use for authentication on the RunDeck instance
-158 * @param password to use for authentication on the RunDeck instance
-159 * @throws IllegalArgumentException if the url, login or password is blank (null, empty or whitespace)
-160 */
-161publicRundeckClient(String url, String login, String password) throws IllegalArgumentException {
-162this(url);
-163 AssertUtil.notBlank(login, "The RunDeck login is mandatory !");
-164 AssertUtil.notBlank(password, "The RunDeck password is mandatory !");
-165this.login = login;
-166this.password = password;
-167this.token = null;
+140private String sessionID;
+141
+142void setToken(String token) {
+143this.token = token;
+144 }
+145
+146void setLogin(String login) {
+147this.login = login;
+148 }
+149
+150void setPassword(String password) {
+151this.password = password;
+152 }
+153
+154void setSessionID(String sessionID) {
+155this.sessionID = sessionID;
+156 }
+157
+158int getApiVersion() {
+159return apiVersion;
+160 }
+161
+162void setApiVersion(int apiVersion) {
+163this.apiVersion = apiVersion;
+164 }
+165
+166void setApiVersion(Version apiVersion) {
+167this.apiVersion = apiVersion.getVersionNumber();
168 }
169
-170/**
-171 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url,
-172 * using token-based or session-based authentication. Either token or sessionID must be valid
-173 *
-174 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
-175 * @param token to use for authentication on the RunDeck instance
-176 * @param sessionID to use for session authentication on the RunDeck instance
-177 * @param useToken should be true if using token, false if using sessionID
-178 * @throws IllegalArgumentException if the url or token is blank (null, empty or whitespace)
-179 * @deprecated Use the builder {@link RundeckClientBuilder}
-180 */
-181publicRundeckClient(String url, String token, String sessionID, boolean useToken) throws IllegalArgumentException {
-182this(url);
-183
-184if(useToken){
-185 AssertUtil.notBlank(token, "Token is mandatory!");
-186this.token = token;
-187this.sessionID = null;
-188 }
-189else {
-190 AssertUtil.notBlank(sessionID, "sessionID is mandatory!");
-191this.sessionID = sessionID;
-192this.token = null;
-193 }
-194this.login = null;
-195this.password = null;
-196 }
-197
-198
-199publicRundeckClient(String url, String token) throws IllegalArgumentException {
-200this(url, token, null, true);
-201 }
-202
-203/**
-204 * Used by RundeckClientBuilder
-205 */
-206RundeckClient(final String url) throws IllegalArgumentException {
-207 AssertUtil.notBlank(url, "The RunDeck URL is mandatory !");
-208this.url=url;
-209 }
-210
-211/**
-212 * Create a builder for RundeckClient
-213 */
-214publicstaticRundeckClientBuilder builder() {
-215returnnewRundeckClientBuilder();
-216 }
-217
-218/**
-219 * Try to "ping" the RunDeck instance to see if it is alive
-220 *
-221 * @throws RundeckApiException if the ping fails
-222 */
-223publicvoid ping() throws RundeckApiException {
-224newApiCall(this).ping();
-225 }
-226
-227/**
-228 * Test the authentication on the RunDeck instance.
-229 *
-230 * @return sessionID if doing username+password login and it succeeded
-231 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-232 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-233 */
-234public String testAuth() throws RundeckApiLoginException, RundeckApiTokenException {
-235return (new ApiCall(this)).testAuth();
-236 }
-237
-238/**
-239 * @deprecated Use {@link #testAuth()}
-240 * @see #testAuth()
-241 */
-242 @Deprecated
-243publicvoid testCredentials() throws RundeckApiLoginException, RundeckApiTokenException {
-244 testAuth();
-245 }
-246
-247/*
-248 * Projects
-249 */
-250
-251/**
-252 * List all projects
-253 *
-254 * @return a {@link List} of {@link RundeckProject} : might be empty, but won't be null
-255 * @throws RundeckApiException in case of error when calling the API
-256 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-257 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-258 */
-259public List<RundeckProject> getProjects() throws RundeckApiException, RundeckApiLoginException,
-260RundeckApiTokenException {
-261returnnewApiCall(this).get(newApiPathBuilder("/projects"),
-262new ListParser<RundeckProject>(newProjectParser(), "result/projects/project"));
-263 }
-264
-265/**
-266 * Get the definition of a single project, identified by the given name
-267 *
-268 * @param projectName name of the project - mandatory
-269 * @return a {@link RundeckProject} instance - won't be null
-270 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-271 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-272 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-273 * @throws IllegalArgumentException if the projectName is blank (null, empty or whitespace)
-274 */
-275publicRundeckProject getProject(String projectName) throws RundeckApiException, RundeckApiLoginException,
-276 RundeckApiTokenException, IllegalArgumentException {
-277 AssertUtil.notBlank(projectName, "projectName is mandatory to get the details of a project !");
-278returnnewApiCall(this).get(newApiPathBuilder("/project/", projectName),
-279newProjectParser("result/projects/project"));
-280 }
-281
-282/*
-283 * Jobs
-284 */
-285
-286/**
-287 * List all jobs (for all projects)
-288 *
-289 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
-290 * @throws RundeckApiException in case of error when calling the API
-291 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-292 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-293 */
-294public List<RundeckJob> getJobs() throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException {
-295 List<RundeckJob> jobs = new ArrayList<RundeckJob>();
-296for (RundeckProject project : getProjects()) {
-297 jobs.addAll(getJobs(project.getName()));
-298 }
-299return jobs;
-300 }
-301
-302/**
-303 * List all jobs that belongs to the given project
-304 *
-305 * @param project name of the project - mandatory
-306 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
-307 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-308 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-309 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-310 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-311 * @see #getJobs(String, String, String, String...)
-312 */
-313public List<RundeckJob> getJobs(String project) throws RundeckApiException, RundeckApiLoginException,
-314 RundeckApiTokenException, IllegalArgumentException {
-315return getJobs(project, null, null, new String[0]);
-316 }
-317
-318/**
-319 * List the jobs that belongs to the given project, and matches the given criteria (jobFilter, groupPath and jobIds)
-320 *
-321 * @param project name of the project - mandatory
-322 * @param jobFilter a filter for the job Name - optional
-323 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-324 * @param jobIds a list of Job IDs to include - optional
-325 * @return a {@link List} of {@link RundeckJob} : might be empty, but 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 fails (in case of login-based authentication)
-328 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-329 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-330 * @see #getJobs(String)
-331 */
-332public List<RundeckJob> getJobs(String project, String jobFilter, String groupPath, String... jobIds)
-333throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-334 AssertUtil.notBlank(project, "project is mandatory to get all jobs !");
-335returnnewApiCall(this).get(newApiPathBuilder("/jobs").param("project", project)
-336 .param("jobFilter", jobFilter)
-337 .param("groupPath", groupPath)
-338 .param("idlist", StringUtils.join(jobIds, ",")),
-339new ListParser<RundeckJob>(newJobParser(), "result/jobs/job"));
-340 }
-341
-342/**
-343 * Export the definitions of all jobs that belongs to the given project
-344 *
-345 * @param filename path of the file where the content should be saved - mandatory
-346 * @param format of the export. See {@link FileType} - mandatory
-347 * @param project name of the project - mandatory
+170 String getApiEndpoint() {
+171return API + getApiVersion();
+172 }
+173
+174/**
+175 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url, using login-based
+176 * authentication.
+177 *
+178 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
+179 * @param login to use for authentication on the RunDeck instance
+180 * @param password to use for authentication on the RunDeck instance
+181 * @throws IllegalArgumentException if the url, login or password is blank (null, empty or whitespace)
+182 */
+183publicRundeckClient(String url, String login, String password) throws IllegalArgumentException {
+184this(url);
+185 AssertUtil.notBlank(login, "The RunDeck login is mandatory !");
+186 AssertUtil.notBlank(password, "The RunDeck password is mandatory !");
+187this.login = login;
+188this.password = password;
+189this.token = null;
+190 }
+191
+192/**
+193 * Instantiate a new {@link RundeckClient} for the RunDeck instance at the given url,
+194 * using token-based or session-based authentication. Either token or sessionID must be valid
+195 *
+196 * @param url of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
+197 * @param token to use for authentication on the RunDeck instance
+198 * @param sessionID to use for session authentication on the RunDeck instance
+199 * @param useToken should be true if using token, false if using sessionID
+200 * @throws IllegalArgumentException if the url or token is blank (null, empty or whitespace)
+201 * @deprecated Use the builder {@link RundeckClientBuilder}, this method will not be public in version 10 of this library.
+202 */
+203publicRundeckClient(String url, String token, String sessionID, boolean useToken) throws IllegalArgumentException {
+204this(url);
+205
+206if(useToken){
+207 AssertUtil.notBlank(token, "Token is mandatory!");
+208this.token = token;
+209this.sessionID = null;
+210 }
+211else {
+212 AssertUtil.notBlank(sessionID, "sessionID is mandatory!");
+213this.sessionID = sessionID;
+214this.token = null;
+215 }
+216this.login = null;
+217this.password = null;
+218 }
+219
+220
+221publicRundeckClient(String url, String token) throws IllegalArgumentException {
+222this(url, token, null, true);
+223 }
+224
+225/**
+226 * Used by RundeckClientBuilder
+227 */
+228RundeckClient(final String url) throws IllegalArgumentException {
+229 AssertUtil.notBlank(url, "The RunDeck URL is mandatory !");
+230this.url=url;
+231 }
+232
+233/**
+234 * Create a builder for RundeckClient
+235 */
+236publicstaticRundeckClientBuilder builder() {
+237returnnewRundeckClientBuilder();
+238 }
+239
+240/**
+241 * Try to "ping" the RunDeck instance to see if it is alive
+242 *
+243 * @throws RundeckApiException if the ping fails
+244 */
+245publicvoid ping() throws RundeckApiException {
+246newApiCall(this).ping();
+247 }
+248
+249/**
+250 * Test the authentication on the RunDeck instance.
+251 *
+252 * @return sessionID if doing username+password login and it succeeded
+253 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+254 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+255 */
+256public String testAuth() throws RundeckApiLoginException, RundeckApiTokenException {
+257return (new ApiCall(this)).testAuth();
+258 }
+259
+260/**
+261 * @deprecated Use {@link #testAuth()}
+262 * @see #testAuth()
+263 */
+264 @Deprecated
+265publicvoid testCredentials() throws RundeckApiLoginException, RundeckApiTokenException {
+266 testAuth();
+267 }
+268
+269/*
+270 * Projects
+271 */
+272
+273/**
+274 * List all projects
+275 *
+276 * @return a {@link List} of {@link RundeckProject} : might be empty, but won't be null
+277 * @throws RundeckApiException in case of error when calling the API
+278 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+279 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+280 */
+281public List<RundeckProject> getProjects() throws RundeckApiException, RundeckApiLoginException,
+282RundeckApiTokenException {
+283returnnewApiCall(this).get(newApiPathBuilder("/projects"),
+284new ListParser<RundeckProject>(newProjectParser(), "result/projects/project"));
+285 }
+286
+287/**
+288 * Get the definition of a single project, identified by the given name
+289 *
+290 * @param projectName name of the project - mandatory
+291 * @return a {@link RundeckProject} instance - won't be null
+292 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+293 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+294 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+295 * @throws IllegalArgumentException if the projectName is blank (null, empty or whitespace)
+296 */
+297publicRundeckProject getProject(String projectName) throws RundeckApiException, RundeckApiLoginException,
+298 RundeckApiTokenException, IllegalArgumentException {
+299 AssertUtil.notBlank(projectName, "projectName is mandatory to get the details of a project !");
+300returnnewApiCall(this).get(newApiPathBuilder("/project/", projectName),
+301newProjectParser("result/projects/project"));
+302 }
+303
+304/*
+305 * Jobs
+306 */
+307
+308/**
+309 * List all jobs (for all projects)
+310 *
+311 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
+312 * @throws RundeckApiException in case of error when calling the API
+313 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+314 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+315 */
+316public List<RundeckJob> getJobs() throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException {
+317 List<RundeckJob> jobs = new ArrayList<RundeckJob>();
+318for (RundeckProject project : getProjects()) {
+319 jobs.addAll(getJobs(project.getName()));
+320 }
+321return jobs;
+322 }
+323
+324/**
+325 * List all jobs that belongs to the given project
+326 *
+327 * @param project name of the project - mandatory
+328 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null
+329 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+330 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+331 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+332 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+333 * @see #getJobs(String, String, String, String...)
+334 */
+335public List<RundeckJob> getJobs(String project) throws RundeckApiException, RundeckApiLoginException,
+336 RundeckApiTokenException, IllegalArgumentException {
+337return getJobs(project, null, null, new String[0]);
+338 }
+339
+340/**
+341 * List the jobs that belongs to the given project, and matches the given criteria (jobFilter, groupPath and jobIds)
+342 *
+343 * @param project name of the project - mandatory
+344 * @param jobFilter a filter for the job Name - optional
+345 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+346 * @param jobIds a list of Job IDs to include - optional
+347 * @return a {@link List} of {@link RundeckJob} : might be empty, but won't be null348 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)349 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)350 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-351 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-352 * invalid
-353 * @throws IOException if we failed to write to the file
-354 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-355 * @see #exportJobs(String, String)
-356 */
-357publicvoid exportJobsToFile(String filename, String format, String project) throws RundeckApiException,
-358 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-359 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-360 exportJobsToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), project);
-361 }
-362
-363/**
-364 * Export the definitions of all jobs that belongs to the given project
-365 *
-366 * @param filename path of the file where the content should be saved - mandatory
-367 * @param format of the export. See {@link FileType} - mandatory
-368 * @param project name of the project - mandatory
-369 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-370 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-371 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-372 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-373 * @throws IOException if we failed to write to the file
-374 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-375 * @see #exportJobs(FileType, String)
-376 */
-377publicvoid exportJobsToFile(String filename, FileType format, String project) throws RundeckApiException,
-378 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-379 exportJobsToFile(filename, format, project, null, null, new String[0]);
-380 }
-381
-382/**
-383 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-384 * groupPath and jobIds)
-385 *
-386 * @param filename path of the file where the content should be saved - mandatory
-387 * @param format of the export. See {@link FileType} - mandatory
-388 * @param project name of the project - mandatory
-389 * @param jobFilter a filter for the job Name - optional
-390 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-391 * @param jobIds a list of Job IDs to include - optional
-392 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-393 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-394 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-395 * @throws IllegalArgumentException if the filename, format or project is blank (null, empty or whitespace), or the
-396 * format is invalid
-397 * @throws IOException if we failed to write to the file
-398 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
-399 * @see #exportJobs(FileType, String, String, String, String...)
-400 */
-401publicvoid exportJobsToFile(String filename, String format, String project, String jobFilter, String groupPath,
-402 String... jobIds) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-403 IllegalArgumentException, IOException {
-404 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-405 exportJobsToFile(filename,
-406 FileType.valueOf(StringUtils.upperCase(format)),
-407 project,
-408 jobFilter,
-409 groupPath,
-410 jobIds);
-411 }
-412
-413/**
-414 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-415 * groupPath and jobIds)
-416 *
-417 * @param filename path of the file where the content should be saved - mandatory
-418 * @param format of the export. See {@link FileType} - mandatory
-419 * @param project name of the project - mandatory
-420 * @param jobFilter a filter for the job Name - optional
-421 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-422 * @param jobIds a list of Job IDs to include - optional
-423 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-424 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-425 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-426 * @throws IllegalArgumentException if the filename or project is blank (null, empty or whitespace), or the format
-427 * is null
-428 * @throws IOException if we failed to write to the file
-429 * @see #exportJobs(FileType, String, String, String, String...)
-430 */
-431publicvoid exportJobsToFile(String filename, FileType format, String project, String jobFilter, String groupPath,
-432 String... jobIds) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-433 IllegalArgumentException, IOException {
-434 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
-435 InputStream inputStream = exportJobs(format, project, jobFilter, groupPath, jobIds);
-436 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
-437 }
-438
-439/**
-440 * Export the definitions of all jobs that belongs to the given project
-441 *
-442 * @param format of the export. See {@link FileType} - mandatory
-443 * @param project name of the project - mandatory
-444 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+351 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+352 * @see #getJobs(String)
+353 */
+354public List<RundeckJob> getJobs(String project, String jobFilter, String groupPath, String... jobIds)
+355throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+356 AssertUtil.notBlank(project, "project is mandatory to get all jobs !");
+357returnnewApiCall(this).get(newApiPathBuilder("/jobs").param("project", project)
+358 .param("jobFilter", jobFilter)
+359 .param("groupPath", groupPath)
+360 .param("idlist", StringUtils.join(jobIds, ",")),
+361new ListParser<RundeckJob>(newJobParser(), "result/jobs/job"));
+362 }
+363
+364/**
+365 * Export the definitions of all jobs that belongs to the given project
+366 *
+367 * @param filename path of the file where the content should be saved - mandatory
+368 * @param format of the export. See {@link FileType} - mandatory
+369 * @param project name of the project - mandatory
+370 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+371 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+372 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+373 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+374 * invalid
+375 * @throws IOException if we failed to write to the file
+376 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+377 * @see #exportJobs(String, String)
+378 */
+379publicvoid exportJobsToFile(String filename, String format, String project) throws RundeckApiException,
+380 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+381 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+382 exportJobsToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), project);
+383 }
+384
+385/**
+386 * Export the definitions of all jobs that belongs to the given project
+387 *
+388 * @param filename path of the file where the content should be saved - mandatory
+389 * @param format of the export. See {@link FileType} - mandatory
+390 * @param project name of the project - mandatory
+391 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+392 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+393 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+394 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+395 * @throws IOException if we failed to write to the file
+396 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+397 * @see #exportJobs(FileType, String)
+398 */
+399publicvoid exportJobsToFile(String filename, FileType format, String project) throws RundeckApiException,
+400 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+401 exportJobsToFile(filename, format, project, null, null, new String[0]);
+402 }
+403
+404/**
+405 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+406 * groupPath and jobIds)
+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 project name of the project - mandatory
+411 * @param jobFilter a filter for the job Name - optional
+412 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+413 * @param jobIds a list of Job IDs to include - optional
+414 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+415 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+416 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+417 * @throws IllegalArgumentException if the filename, format or project is blank (null, empty or whitespace), or the
+418 * format is invalid
+419 * @throws IOException if we failed to write to the file
+420 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+421 * @see #exportJobs(FileType, String, String, String, String...)
+422 */
+423publicvoid exportJobsToFile(String filename, String format, String project, String jobFilter, String groupPath,
+424 String... jobIds) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+425 IllegalArgumentException, IOException {
+426 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+427 exportJobsToFile(filename,
+428 FileType.valueOf(StringUtils.upperCase(format)),
+429 project,
+430 jobFilter,
+431 groupPath,
+432 jobIds);
+433 }
+434
+435/**
+436 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+437 * groupPath and jobIds)
+438 *
+439 * @param filename path of the file where the content should be saved - mandatory
+440 * @param format of the export. See {@link FileType} - mandatory
+441 * @param project name of the project - mandatory
+442 * @param jobFilter a filter for the job Name - optional
+443 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+444 * @param jobIds a list of Job IDs to include - optional445 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)446 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)447 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-448 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-449 * invalid
-450 * @see #exportJobs(FileType, String, String, String, String...)
-451 * @see #exportJobsToFile(String, String, String)
+448 * @throws IllegalArgumentException if the filename or project is blank (null, empty or whitespace), or the format
+449 * is null
+450 * @throws IOException if we failed to write to the file
+451 * @see #exportJobs(FileType, String, String, String, String...)452 */
-453public InputStream exportJobs(String format, String project) throws RundeckApiException, RundeckApiLoginException,
-454 RundeckApiTokenException, IllegalArgumentException {
-455 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-456return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project);
-457 }
-458
-459/**
-460 * Export the definitions of all jobs that belongs to the given project
-461 *
-462 * @param format of the export. See {@link FileType} - mandatory
-463 * @param project name of the project - mandatory
-464 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-465 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-466 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-467 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-468 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-469 * @see #exportJobs(FileType, String, String, String, String...)
-470 * @see #exportJobsToFile(String, FileType, String)
-471 */
-472public InputStream exportJobs(FileType format, String project) throws RundeckApiException,
-473 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-474return exportJobs(format, project, null, null, new String[0]);
-475 }
-476
-477/**
-478 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-479 * groupPath and jobIds)
-480 *
-481 * @param format of the export. See {@link FileType} - mandatory
-482 * @param project name of the project - mandatory
-483 * @param jobFilter a filter for the job Name - optional
-484 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-485 * @param jobIds a list of Job IDs to include - optional
+453publicvoid exportJobsToFile(String filename, FileType format, String project, String jobFilter, String groupPath,
+454 String... jobIds) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+455 IllegalArgumentException, IOException {
+456 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
+457 InputStream inputStream = exportJobs(format, project, jobFilter, groupPath, jobIds);
+458 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
+459 }
+460
+461/**
+462 * Export the definitions of all jobs that belongs to the given project
+463 *
+464 * @param format of the export. See {@link FileType} - mandatory
+465 * @param project name of the project - mandatory
+466 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+467 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+468 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+469 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+470 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+471 * invalid
+472 * @see #exportJobs(FileType, String, String, String, String...)
+473 * @see #exportJobsToFile(String, String, String)
+474 */
+475public InputStream exportJobs(String format, String project) throws RundeckApiException, RundeckApiLoginException,
+476 RundeckApiTokenException, IllegalArgumentException {
+477 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+478return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project);
+479 }
+480
+481/**
+482 * Export the definitions of all jobs that belongs to the given project
+483 *
+484 * @param format of the export. See {@link FileType} - mandatory
+485 * @param project name of the project - mandatory486 * @return an {@link InputStream} instance, not linked to any network resources - won't be null487 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)488 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)489 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-490 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
-491 * invalid
-492 * @see #exportJobs(FileType, String, String, String, String...)
-493 * @see #exportJobsToFile(String, String, String, String, String, String...)
-494 */
-495public InputStream exportJobs(String format, String project, String jobFilter, String groupPath, String... jobIds)
-496throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-497 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
-498return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project, jobFilter, groupPath, jobIds);
-499 }
-500
-501/**
-502 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
-503 * groupPath and jobIds)
-504 *
-505 * @param format of the export. See {@link FileType} - mandatory
-506 * @param project name of the project - mandatory
-507 * @param jobFilter a filter for the job Name - optional
-508 * @param groupPath a group or partial group path to include all jobs within that group path - optional
-509 * @param jobIds a list of Job IDs to include - optional
-510 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-511 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-512 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-513 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-514 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
-515 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+490 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+491 * @see #exportJobs(FileType, String, String, String, String...)
+492 * @see #exportJobsToFile(String, FileType, String)
+493 */
+494public InputStream exportJobs(FileType format, String project) throws RundeckApiException,
+495 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+496return exportJobs(format, project, null, null, new String[0]);
+497 }
+498
+499/**
+500 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+501 * groupPath and jobIds)
+502 *
+503 * @param format of the export. See {@link FileType} - mandatory
+504 * @param project name of the project - mandatory
+505 * @param jobFilter a filter for the job Name - optional
+506 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+507 * @param jobIds a list of Job IDs to include - optional
+508 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+509 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+510 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+511 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+512 * @throws IllegalArgumentException if the format or project is blank (null, empty or whitespace), or the format is
+513 * invalid
+514 * @see #exportJobs(FileType, String, String, String, String...)
+515 * @see #exportJobsToFile(String, String, String, String, String, String...)516 */
-517public InputStream exportJobs(FileType format, String project, String jobFilter, String groupPath, String... jobIds)
+517public InputStream exportJobs(String format, String project, String jobFilter, String groupPath, String... jobIds)
518throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-519 AssertUtil.notNull(format, "format is mandatory to export jobs !");
-520 AssertUtil.notBlank(project, "project is mandatory to export jobs !");
-521returnnewApiCall(this).get(newApiPathBuilder("/jobs/export").param("format", format)
-522 .param("project", project)
-523 .param("jobFilter", jobFilter)
-524 .param("groupPath", groupPath)
-525 .param("idlist", StringUtils.join(jobIds, ",")));
-526 }
-527
-528/**
-529 * Export the definition of a single job (identified by the given ID)
-530 *
-531 * @param filename path of the file where the content should be saved - mandatory
-532 * @param format of the export. See {@link FileType} - mandatory
-533 * @param jobId identifier of the job - mandatory
-534 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-535 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-536 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-537 * @throws IllegalArgumentException if the filename, format or jobId is blank (null, empty or whitespace), or the
-538 * format is invalid
-539 * @throws IOException if we failed to write to the file
-540 * @see #exportJobToFile(String, FileType, String)
-541 * @see #exportJob(String, String)
-542 * @see #getJob(String)
-543 */
-544publicvoid exportJobToFile(String filename, String format, String jobId) throws RundeckApiException,
-545 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-546 AssertUtil.notBlank(format, "format is mandatory to export a job !");
-547 exportJobToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), jobId);
+519 AssertUtil.notBlank(format, "format is mandatory to export jobs !");
+520return exportJobs(FileType.valueOf(StringUtils.upperCase(format)), project, jobFilter, groupPath, jobIds);
+521 }
+522
+523/**
+524 * Export the definitions of the jobs that belongs to the given project, and matches the given criteria (jobFilter,
+525 * groupPath and jobIds)
+526 *
+527 * @param format of the export. See {@link FileType} - mandatory
+528 * @param project name of the project - mandatory
+529 * @param jobFilter a filter for the job Name - optional
+530 * @param groupPath a group or partial group path to include all jobs within that group path - optional
+531 * @param jobIds a list of Job IDs to include - optional
+532 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+533 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+534 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+535 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+536 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the format is null
+537 * @see #exportJobsToFile(String, FileType, String, String, String, String...)
+538 */
+539public InputStream exportJobs(FileType format, String project, String jobFilter, String groupPath, String... jobIds)
+540throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+541 AssertUtil.notNull(format, "format is mandatory to export jobs !");
+542 AssertUtil.notBlank(project, "project is mandatory to export jobs !");
+543returnnewApiCall(this).get(newApiPathBuilder("/jobs/export").param("format", format)
+544 .param("project", project)
+545 .param("jobFilter", jobFilter)
+546 .param("groupPath", groupPath)
+547 .param("idlist", StringUtils.join(jobIds, ",")));
548 }
549550/**551 * Export the definition of a single job (identified by the given ID)
-552 *
+552 *553 * @param filename path of the file where the content should be saved - mandatory554 * @param format of the export. See {@link FileType} - mandatory555 * @param jobId identifier of the job - mandatory556 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)557 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)558 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-559 * @throws IllegalArgumentException if the filename or jobId is blank (null, empty or whitespace), or the format is
-560 * null
+559 * @throws IllegalArgumentException if the filename, format or jobId is blank (null, empty or whitespace), or the
+560 * format is invalid561 * @throws IOException if we failed to write to the file
-562 * @see #exportJob(FileType, String)
-563 * @see #getJob(String)
-564 */
-565publicvoid exportJobToFile(String filename, FileType format, String jobId) throws RundeckApiException,
-566 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-567 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
-568 InputStream inputStream = exportJob(format, jobId);
-569 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
+562 * @see #exportJobToFile(String, FileType, String)
+563 * @see #exportJob(String, String)
+564 * @see #getJob(String)
+565 */
+566publicvoid exportJobToFile(String filename, String format, String jobId) throws RundeckApiException,
+567 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+568 AssertUtil.notBlank(format, "format is mandatory to export a job !");
+569 exportJobToFile(filename, FileType.valueOf(StringUtils.upperCase(format)), jobId);
570 }
571572/**
-573 * Export the definition of a single job, identified by the given ID
-574 *
-575 * @param format of the export. See {@link FileType} - mandatory
-576 * @param jobId identifier of the job - mandatory
-577 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+573 * Export the definition of a single job (identified by the given ID)
+574 *
+575 * @param filename path of the file where the content should be saved - mandatory
+576 * @param format of the export. See {@link FileType} - mandatory
+577 * @param jobId identifier of the job - mandatory578 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)579 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)580 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-581 * @throws IllegalArgumentException if the format or jobId is blank (null, empty or whitespace), or the format is
-582 * invalid
-583 * @see #exportJobToFile(String, String, String)
-584 * @see #getJob(String)
-585 */
-586public InputStream exportJob(String format, String jobId) throws RundeckApiException, RundeckApiLoginException,
-587 RundeckApiTokenException, IllegalArgumentException {
-588 AssertUtil.notBlank(format, "format is mandatory to export a job !");
-589return exportJob(FileType.valueOf(StringUtils.upperCase(format)), jobId);
-590 }
-591
-592/**
-593 * Export the definition of a single job, identified by the given ID
-594 *
-595 * @param format of the export. See {@link FileType} - mandatory
-596 * @param jobId identifier of the job - mandatory
-597 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-598 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-599 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-600 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-601 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the format is null
-602 * @see #exportJobToFile(String, FileType, String)
-603 * @see #getJob(String)
-604 */
-605public InputStream exportJob(FileType format, String jobId) throws RundeckApiException, RundeckApiLoginException,
-606 RundeckApiTokenException, IllegalArgumentException {
-607 AssertUtil.notNull(format, "format is mandatory to export a job !");
-608 AssertUtil.notBlank(jobId, "jobId is mandatory to export a job !");
-609returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId).param("format", format));
-610 }
-611
-612/**
-613 * Import the definitions of jobs, from the given file
-614 *
-615 * @param filename of the file containing the jobs definitions - mandatory
-616 * @param fileType type of the file. See {@link FileType} - mandatory
-617 * @return a {@link RundeckJobsImportResult} instance - won't be null
-618 * @throws RundeckApiException in case of error when calling the API
-619 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-620 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-621 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
-622 * fileType is invalid
-623 * @throws IOException if we failed to read the file
-624 * @see #importJobs(InputStream, String)
-625 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+581 * @throws IllegalArgumentException if the filename or jobId is blank (null, empty or whitespace), or the format is
+582 * null
+583 * @throws IOException if we failed to write to the file
+584 * @see #exportJob(FileType, String)
+585 * @see #getJob(String)
+586 */
+587publicvoid exportJobToFile(String filename, FileType format, String jobId) throws RundeckApiException,
+588 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+589 AssertUtil.notBlank(filename, "filename is mandatory to export a job !");
+590 InputStream inputStream = exportJob(format, jobId);
+591 FileUtils.writeByteArrayToFile(new File(filename), IOUtils.toByteArray(inputStream));
+592 }
+593
+594/**
+595 * Export the definition of a single job, identified by the given ID
+596 *
+597 * @param format of the export. See {@link FileType} - mandatory
+598 * @param jobId identifier of the job - mandatory
+599 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+600 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+601 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+602 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+603 * @throws IllegalArgumentException if the format or jobId is blank (null, empty or whitespace), or the format is
+604 * invalid
+605 * @see #exportJobToFile(String, String, String)
+606 * @see #getJob(String)
+607 */
+608public InputStream exportJob(String format, String jobId) throws RundeckApiException, RundeckApiLoginException,
+609 RundeckApiTokenException, IllegalArgumentException {
+610 AssertUtil.notBlank(format, "format is mandatory to export a job !");
+611return exportJob(FileType.valueOf(StringUtils.upperCase(format)), jobId);
+612 }
+613
+614/**
+615 * Export the definition of a single job, identified by the given ID
+616 *
+617 * @param format of the export. See {@link FileType} - mandatory
+618 * @param jobId identifier of the job - mandatory
+619 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+620 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+621 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+622 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+623 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the format is null
+624 * @see #exportJobToFile(String, FileType, String)
+625 * @see #getJob(String)626 */
-627publicRundeckJobsImportResult importJobs(String filename, String fileType) throws RundeckApiException,
-628 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-629 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-630return importJobs(filename, FileType.valueOf(StringUtils.upperCase(fileType)));
-631 }
-632
-633/**
-634 * Import the definitions of jobs, from the given file
-635 *
-636 * @param filename of the file containing the jobs definitions - mandatory
-637 * @param fileType type of the file. See {@link FileType} - mandatory
-638 * @return a {@link RundeckJobsImportResult} instance - won't be null
-639 * @throws RundeckApiException in case of error when calling the API
-640 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-641 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-642 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
-643 * @throws IOException if we failed to read the file
-644 * @see #importJobs(InputStream, FileType)
-645 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-646 */
-647publicRundeckJobsImportResult importJobs(String filename, FileType fileType) throws RundeckApiException,
-648 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-649return importJobs(filename, fileType, (RundeckJobsImportMethod) null);
-650 }
-651
-652/**
-653 * Import the definitions of jobs, from the given file, using the given behavior
-654 *
-655 * @param filename of the file containing the jobs definitions - mandatory
-656 * @param fileType type of the file. See {@link FileType} - mandatory
-657 * @param importBehavior see {@link RundeckJobsImportMethod}
-658 * @return a {@link RundeckJobsImportResult} instance - won't be null
-659 * @throws RundeckApiException in case of error when calling the API
-660 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-661 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-662 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
-663 * fileType or behavior is not valid
-664 * @throws IOException if we failed to read the file
-665 * @see #importJobs(InputStream, String, String)
-666 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-667 */
-668publicRundeckJobsImportResult importJobs(String filename, String fileType, String importBehavior)
-669throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
-670 IOException {
-671 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-672return importJobs(filename,
-673 FileType.valueOf(StringUtils.upperCase(fileType)),
-674 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
+627public InputStream exportJob(FileType format, String jobId) throws RundeckApiException, RundeckApiLoginException,
+628 RundeckApiTokenException, IllegalArgumentException {
+629 AssertUtil.notNull(format, "format is mandatory to export a job !");
+630 AssertUtil.notBlank(jobId, "jobId is mandatory to export a job !");
+631returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId).param("format", format));
+632 }
+633
+634/**
+635 * Import the definitions of jobs, from the given file
+636 *
+637 * @param filename of the file containing the jobs definitions - mandatory
+638 * @param fileType type of the file. See {@link FileType} - mandatory
+639 * @return a {@link RundeckJobsImportResult} instance - won't be null
+640 * @throws RundeckApiException in case of error when calling the API
+641 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+642 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+643 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
+644 * fileType is invalid
+645 * @throws IOException if we failed to read the file
+646 * @see #importJobs(InputStream, String)
+647 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+648 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this library.
+649 */
+650publicRundeckJobsImportResult importJobs(String filename, String fileType) throws RundeckApiException,
+651 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+652 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+653return importJobs(filename, FileType.valueOf(StringUtils.upperCase(fileType)));
+654 }
+655
+656/**
+657 * Import the definitions of jobs, from the given file
+658 *
+659 * @param filename of the file containing the jobs definitions - mandatory
+660 * @param fileType type of the file. See {@link FileType} - mandatory
+661 * @return a {@link RundeckJobsImportResult} instance - won't be null
+662 * @throws RundeckApiException in case of error when calling the API
+663 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+664 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+665 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
+666 * @throws IOException if we failed to read the file
+667 * @see #importJobs(InputStream, FileType)
+668 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+669 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+670 * library.
+671 */
+672publicRundeckJobsImportResult importJobs(String filename, FileType fileType) throws RundeckApiException,
+673 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+674return importJobs(filename, fileType, (RundeckJobsImportMethod) null);
675 }
676677/**678 * Import the definitions of jobs, from the given file, using the given behavior
-679 *
+679 *680 * @param filename of the file containing the jobs definitions - mandatory681 * @param fileType type of the file. See {@link FileType} - mandatory682 * @param importBehavior see {@link RundeckJobsImportMethod}
@@ -694,1992 +694,2722 @@
684 * @throws RundeckApiException in case of error when calling the API685 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)686 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-687 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
-688 * @throws IOException if we failed to read the file
-689 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-690 */
-691publicRundeckJobsImportResult importJobs(String filename, FileType fileType, RundeckJobsImportMethod importBehavior)
-692throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
-693 IOException {
-694 AssertUtil.notBlank(filename, "filename (of jobs file) is mandatory to import jobs !");
-695 FileInputStream stream = null;
-696try {
-697 stream = FileUtils.openInputStream(new File(filename));
-698return importJobs(stream, fileType, importBehavior);
-699 } finally {
-700 IOUtils.closeQuietly(stream);
-701 }
+687 * @throws IllegalArgumentException if the filename or fileType is blank (null, empty or whitespace), or the
+688 * fileType or behavior is not valid
+689 * @throws IOException if we failed to read the file
+690 * @see #importJobs(InputStream, String, String)
+691 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+692 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+693 * library.
+694 */
+695publicRundeckJobsImportResult importJobs(String filename, String fileType, String importBehavior)
+696throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
+697 IOException {
+698 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+699return importJobs(filename,
+700 FileType.valueOf(StringUtils.upperCase(fileType)),
+701 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
702 }
703704/**
-705 * Import the definitions of jobs, from the given input stream
-706 *
-707 * @param stream inputStream for reading the definitions - mandatory
+705 * Import the definitions of jobs, from the given file, using the given behavior
+706 *
+707 * @param filename of the file containing the jobs definitions - mandatory708 * @param fileType type of the file. See {@link FileType} - mandatory
-709 * @return a {@link RundeckJobsImportResult} instance - won't be null
-710 * @throws RundeckApiException in case of error when calling the API
-711 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-712 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-713 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace) or
-714 * invalid
-715 * @see #importJobs(String, String)
+709 * @param importBehavior see {@link RundeckJobsImportMethod}
+710 * @return a {@link RundeckJobsImportResult} instance - won't be null
+711 * @throws RundeckApiException in case of error when calling the API
+712 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+713 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+714 * @throws IllegalArgumentException if the filename is blank (null, empty or whitespace), or the fileType is null
+715 * @throws IOException if we failed to read the file716 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-717 */
-718publicRundeckJobsImportResult importJobs(InputStream stream, String fileType) throws RundeckApiException,
-719 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-720 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-721return importJobs(stream, FileType.valueOf(StringUtils.upperCase(fileType)));
-722 }
-723
-724/**
-725 * Import the definitions of jobs, from the given input stream
-726 *
-727 * @param stream inputStream for reading the definitions - mandatory
-728 * @param fileType type of the file. See {@link FileType} - mandatory
-729 * @return a {@link RundeckJobsImportResult} instance - won't be null
-730 * @throws RundeckApiException in case of error when calling the API
-731 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-732 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-733 * @throws IllegalArgumentException if the stream or fileType is null
-734 * @see #importJobs(String, FileType)
-735 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-736 */
-737publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType) throws RundeckApiException,
-738 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-739return importJobs(stream, fileType, (RundeckJobsImportMethod) null);
-740 }
-741
-742/**
-743 * Import the definitions of jobs, from the given input stream, using the given behavior
-744 *
-745 * @param stream inputStream for reading the definitions - mandatory
-746 * @param fileType type of the file. See {@link FileType} - mandatory
-747 * @param importBehavior see {@link RundeckJobsImportMethod}
-748 * @return a {@link RundeckJobsImportResult} instance - won't be null
-749 * @throws RundeckApiException in case of error when calling the API
-750 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-751 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-752 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace), or
-753 * the fileType or behavior is not valid
-754 * @see #importJobs(String, String, String)
-755 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
-756 */
-757publicRundeckJobsImportResult importJobs(InputStream stream, String fileType, String importBehavior)
-758throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-759 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
-760return importJobs(stream,
-761 FileType.valueOf(StringUtils.upperCase(fileType)),
-762 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
-763 }
-764
-765/**
-766 * Import the definitions of jobs, from the given input stream, using the given behavior
-767 *
-768 * @param stream inputStream for reading the definitions - mandatory
-769 * @param fileType type of the file. See {@link FileType} - mandatory
-770 * @param importBehavior see {@link RundeckJobsImportMethod}
-771 * @return a {@link RundeckJobsImportResult} instance - won't be null
-772 * @throws RundeckApiException in case of error when calling the API
-773 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-774 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-775 * @throws IllegalArgumentException if the stream or fileType is null
-776 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
-777 */
-778publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType,
-779RundeckJobsImportMethod importBehavior) throws RundeckApiException, RundeckApiLoginException,
-780 RundeckApiTokenException, IllegalArgumentException {
-781 AssertUtil.notNull(stream, "inputStream of jobs is mandatory to import jobs !");
-782 AssertUtil.notNull(fileType, "fileType is mandatory to import jobs !");
-783returnnewApiCall(this).post(newApiPathBuilder("/jobs/import").param("format", fileType)
-784 .param("dupeOption", importBehavior)
-785 .attach("xmlBatch", stream),
-786newJobsImportResultParser("result"));
-787 }
-788
-789/**
-790 * Find a job, identified by its project, group and name. Note that the groupPath is optional, as a job does not
-791 * need to belong to a group (either pass null, or an empty string).
-792 *
-793 * @param project name of the project - mandatory
-794 * @param groupPath group to which the job belongs (if it belongs to a group) - optional
-795 * @param name of the job to find - mandatory
-796 * @return a {@link RundeckJob} instance - null if not found
-797 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-798 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-799 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-800 * @throws IllegalArgumentException if the project or the name is blank (null, empty or whitespace)
-801 * @see #getJob(String)
-802 */
-803publicRundeckJob findJob(String project, String groupPath, String name) throws RundeckApiException,
-804 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-805 AssertUtil.notBlank(project, "project is mandatory to find a job !");
-806 AssertUtil.notBlank(name, "job name is mandatory to find a job !");
-807 List<RundeckJob> jobs = getJobs(project, name, groupPath, new String[0]);
-808return jobs.isEmpty() ? null : jobs.get(0);
-809 }
-810
-811/**
-812 * Get the definition of a single job, identified by the given ID
-813 *
-814 * @param jobId identifier of the job - mandatory
-815 * @return a {@link RundeckJob} instance - won't be null
-816 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-817 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-818 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-819 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-820 * @see #findJob(String, String, String)
-821 * @see #exportJob(String, String)
-822 */
-823publicRundeckJob getJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-824 RundeckApiTokenException, IllegalArgumentException {
-825 AssertUtil.notBlank(jobId, "jobId is mandatory to get the details of a job !");
-826returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId), newJobParser("joblist/job"));
-827 }
-828
-829/**
-830 * Delete a single job, identified by the given ID
-831 *
-832 * @param jobId identifier of the job - mandatory
-833 * @return the success message (note that in case of error, you'll get an exception)
-834 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-835 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-836 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-837 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-838 */
-839public String deleteJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-840 RundeckApiTokenException, IllegalArgumentException {
-841 AssertUtil.notBlank(jobId, "jobId is mandatory to delete a job !");
-842returnnewApiCall(this).delete(newApiPathBuilder("/job/", jobId), newStringParser("result/success/message"));
-843 }
-844/**
-845 * Delete multiple jobs, identified by the given IDs
-846 *
-847 * @param jobIds List of job IDS
-848 * @return the bulk delete result
-849 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-850 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-851 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-852 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-853 */
-854publicRundeckJobDeleteBulk deleteJobs(final List<String> jobIds) throws RundeckApiException, RundeckApiLoginException,
-855 RundeckApiTokenException, IllegalArgumentException {
-856if (null == jobIds || 0 == jobIds.size()) {
-857thrownew IllegalArgumentException("jobIds are mandatory to delete a job");
-858 }
-859returnnewApiCall(this).post(newApiPathBuilder("/jobs/delete").field("ids",jobIds),
-860newBulkDeleteParser("result/deleteJobs"));
-861 }
-862
-863/**
-864 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-865 * end of the job execution)
-866 *
-867 * @param jobId identifier of the job - mandatory
-868 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-869 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-870 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-871 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-872 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-873 * @see #triggerJob(String, Properties, Properties)
-874 * @see #runJob(String)
-875 */
-876publicRundeckExecution triggerJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-877 RundeckApiTokenException, IllegalArgumentException {
-878return triggerJob(jobId, null);
-879 }
-880
-881/**
-882 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-883 * end of the job execution)
-884 *
-885 * @param jobId identifier of the job - mandatory
-886 * @param options of the job - optional. See {@link OptionsBuilder}.
-887 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-888 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-889 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-890 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-891 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-892 * @see #triggerJob(String, Properties, Properties)
-893 * @see #runJob(String, Properties)
-894 */
-895publicRundeckExecution triggerJob(String jobId, Properties options) throws RundeckApiException,
-896 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-897return triggerJob(jobId, options, null);
+717 * @deprecated use {@link #importJobs(String, RundeckJobsImport)}, this method will be removed in version 10 of
+718 * this library.
+719 */
+720publicRundeckJobsImportResult importJobs(String filename, FileType fileType, RundeckJobsImportMethod importBehavior)
+721throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
+722 IOException {
+723 AssertUtil.notBlank(filename, "filename (of jobs file) is mandatory to import jobs !");
+724 FileInputStream stream = null;
+725try {
+726 stream = FileUtils.openInputStream(new File(filename));
+727return importJobs(stream, fileType, importBehavior);
+728 } finally {
+729 IOUtils.closeQuietly(stream);
+730 }
+731 }
+732
+733/**
+734 * Import the definitions of jobs, from the given input stream
+735 *
+736 * @param stream inputStream for reading the definitions - mandatory
+737 * @param fileType type of the file. See {@link FileType} - mandatory
+738 * @return a {@link RundeckJobsImportResult} instance - won't be null
+739 * @throws RundeckApiException in case of error when calling the API
+740 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+741 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+742 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace) or
+743 * invalid
+744 * @see #importJobs(String, String)
+745 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+746 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+747 * library.
+748 */
+749publicRundeckJobsImportResult importJobs(InputStream stream, String fileType) throws RundeckApiException,
+750 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+751 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+752return importJobs(stream, FileType.valueOf(StringUtils.upperCase(fileType)));
+753 }
+754
+755/**
+756 * Import the definitions of jobs, from the given input stream
+757 *
+758 * @param stream inputStream for reading the definitions - mandatory
+759 * @param fileType type of the file. See {@link FileType} - mandatory
+760 * @return a {@link RundeckJobsImportResult} instance - won't be null
+761 * @throws RundeckApiException in case of error when calling the API
+762 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+763 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+764 * @throws IllegalArgumentException if the stream or fileType is null
+765 * @see #importJobs(String, FileType)
+766 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+767 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+768 * library.
+769 */
+770publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType) throws RundeckApiException,
+771 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+772return importJobs(stream, fileType, (RundeckJobsImportMethod) null);
+773 }
+774
+775/**
+776 * Import the definitions of jobs, from the given input stream, using the given behavior
+777 *
+778 * @param stream inputStream for reading the definitions - mandatory
+779 * @param fileType type of the file. See {@link FileType} - mandatory
+780 * @param importBehavior see {@link RundeckJobsImportMethod}
+781 * @return a {@link RundeckJobsImportResult} instance - won't be null
+782 * @throws RundeckApiException in case of error when calling the API
+783 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+784 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+785 * @throws IllegalArgumentException if the stream is null, or the fileType is blank (null, empty or whitespace), or
+786 * the fileType or behavior is not valid
+787 * @see #importJobs(String, String, String)
+788 * @see #importJobs(InputStream, FileType, RundeckJobsImportMethod)
+789 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+790 * library.
+791 */
+792publicRundeckJobsImportResult importJobs(InputStream stream, String fileType, String importBehavior)
+793throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+794 AssertUtil.notBlank(fileType, "fileType is mandatory to import jobs !");
+795return importJobs(stream,
+796 FileType.valueOf(StringUtils.upperCase(fileType)),
+797 RundeckJobsImportMethod.valueOf(StringUtils.upperCase(importBehavior)));
+798 }
+799
+800/**
+801 * Import the definitions of jobs, from the given input stream, using the given behavior
+802 *
+803 * @param stream inputStream for reading the definitions - mandatory
+804 * @param fileType type of the file. See {@link FileType} - mandatory
+805 * @param importBehavior see {@link RundeckJobsImportMethod}
+806 * @return a {@link RundeckJobsImportResult} instance - won't be null
+807 * @throws RundeckApiException in case of error when calling the API
+808 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+809 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+810 * @throws IllegalArgumentException if the stream or fileType is null
+811 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+812 * @deprecated use {@link #importJobs(RundeckJobsImport)}, this method will be removed in version 10 of this
+813 * library.
+814 */
+815publicRundeckJobsImportResult importJobs(InputStream stream, FileType fileType,
+816RundeckJobsImportMethod importBehavior) throws RundeckApiException, RundeckApiLoginException,
+817 RundeckApiTokenException, IllegalArgumentException {
+818return importJobs(RundeckJobsImportBuilder.builder().setStream(stream).setFileType(fileType)
+819 .setJobsImportMethod(importBehavior).build());
+820 }
+821
+822/**
+823 * Import the definitions of jobs, from the given input stream, using the given behavior
+824 *
+825 * @param rundeckJobsImport import request, see {@link RundeckJobsImportBuilder}
+826 *
+827 * @return a {@link RundeckJobsImportResult} instance - won't be null
+828 *
+829 * @throws RundeckApiException in case of error when calling the API
+830 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+831 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+832 * @throws IllegalArgumentException if the stream or fileType is null
+833 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+834 */
+835publicRundeckJobsImportResult importJobs(final String filename,finalRundeckJobsImport rundeckJobsImport) throws RundeckApiException,
+836 RundeckApiLoginException,
+837 RundeckApiTokenException, IllegalArgumentException, IOException {
+838 AssertUtil.notBlank(filename, "filename (of jobs file) is mandatory to import jobs !");
+839 FileInputStream stream = null;
+840try {
+841 stream = FileUtils.openInputStream(new File(filename));
+842return importJobs(RundeckJobsImportBuilder.builder(rundeckJobsImport).setStream(stream).build());
+843 } finally {
+844
+845 IOUtils.closeQuietly(stream);
+846 }
+847 }
+848/**
+849 * Import the definitions of jobs, from the given input stream, using the given behavior
+850 *
+851 * @param rundeckJobsImport import request, see {@link RundeckJobsImportBuilder}
+852 *
+853 * @return a {@link RundeckJobsImportResult} instance - won't be null
+854 *
+855 * @throws RundeckApiException in case of error when calling the API
+856 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+857 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+858 * @throws IllegalArgumentException if the stream or fileType is null
+859 * @see #importJobs(String, FileType, RundeckJobsImportMethod)
+860 */
+861publicRundeckJobsImportResult importJobs(finalRundeckJobsImport rundeckJobsImport) throws RundeckApiException,
+862 RundeckApiLoginException,
+863 RundeckApiTokenException, IllegalArgumentException {
+864
+865 AssertUtil.notNull(rundeckJobsImport.getStream(), "inputStream of jobs is mandatory to import jobs !");
+866 AssertUtil.notNull(rundeckJobsImport.getFileType(), "fileType is mandatory to import jobs !");
+867finalApiPathBuilder request = newApiPathBuilder(JOBS_IMPORT)
+868 .param("format", rundeckJobsImport.getFileType())
+869 .param("dupeOption", rundeckJobsImport.getImportMethod())
+870 .attach("xmlBatch", rundeckJobsImport.getStream());
+871if(null!=rundeckJobsImport.getProject()) {
+872//API v8
+873 request.param("project", rundeckJobsImport.getProject());
+874 }
+875returnnewApiCall(this).post(request, newJobsImportResultParser("result"));
+876 }
+877
+878/**
+879 * Find a job, identified by its project, group and name. Note that the groupPath is optional, as a job does not
+880 * need to belong to a group (either pass null, or an empty string).
+881 *
+882 * @param project name of the project - mandatory
+883 * @param groupPath group to which the job belongs (if it belongs to a group) - optional
+884 * @param name of the job to find - mandatory
+885 * @return a {@link RundeckJob} instance - null if not found
+886 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+887 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+888 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+889 * @throws IllegalArgumentException if the project or the name is blank (null, empty or whitespace)
+890 * @see #getJob(String)
+891 */
+892publicRundeckJob findJob(String project, String groupPath, String name) throws RundeckApiException,
+893 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+894 AssertUtil.notBlank(project, "project is mandatory to find a job !");
+895 AssertUtil.notBlank(name, "job name is mandatory to find a job !");
+896 List<RundeckJob> jobs = getJobs(project, name, groupPath, new String[0]);
+897return jobs.isEmpty() ? null : jobs.get(0);
898 }
899900/**
-901 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
-902 * end of the job execution)
-903 *
-904 * @param jobId identifier of the job - mandatory
-905 * @param options of the job - optional. See {@link OptionsBuilder}.
-906 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-907 * {@link NodeFiltersBuilder}
-908 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-909 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-910 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-911 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-912 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-913 * @see #triggerJob(String)
-914 * @see #runJob(String, Properties, Properties)
-915 */
-916publicRundeckExecution triggerJob(String jobId, Properties options, Properties nodeFilters)
-917throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-918 AssertUtil.notBlank(jobId, "jobId is mandatory to trigger a job !");
-919returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/run").param("argString",
-920 ParametersUtil.generateArgString(options))
-921 .nodeFilters(nodeFilters),
-922newExecutionParser("result/executions/execution"));
-923 }
-924
-925/**
-926 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-927 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-928 * aborted) or is still running.
-929 *
-930 * @param jobId identifier of the job - mandatory
-931 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-932 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-933 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-934 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-935 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-936 * @see #triggerJob(String)
-937 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-938 */
-939publicRundeckExecution runJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
-940 RundeckApiTokenException, IllegalArgumentException {
-941return runJob(jobId, null);
-942 }
-943
-944/**
-945 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-946 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-947 * aborted) or is still running.
-948 *
-949 * @param jobId identifier of the job - mandatory
-950 * @param options of the job - optional. See {@link OptionsBuilder}.
-951 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-952 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-953 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-954 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-955 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-956 * @see #triggerJob(String, Properties)
-957 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-958 */
-959publicRundeckExecution runJob(String jobId, Properties options) throws RundeckApiException,
-960 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-961return runJob(jobId, options, null);
-962 }
-963
-964/**
-965 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-966 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
-967 * aborted) or is still running.
-968 *
-969 * @param jobId identifier of the job - mandatory
-970 * @param options of the job - optional. See {@link OptionsBuilder}.
-971 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-972 * {@link NodeFiltersBuilder}
-973 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-974 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-975 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-976 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-977 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-978 * @see #triggerJob(String, Properties, Properties)
-979 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-980 */
-981publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters)
-982throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-983return runJob(jobId, options, nodeFilters, DEFAULT_POOLING_INTERVAL, DEFAULT_POOLING_UNIT);
-984 }
-985
-986/**
-987 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-988 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
-989 * know if the execution is finished (or aborted) or is still running.
-990 *
-991 * @param jobId identifier of the job - mandatory
-992 * @param options of the job - optional. See {@link OptionsBuilder}.
-993 * @param poolingInterval for checking the status of the execution. Must be > 0.
-994 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-995 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-996 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-997 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-998 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-999 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1000 * @see #triggerJob(String, Properties)
-1001 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-1002 */
-1003publicRundeckExecution runJob(String jobId, Properties options, long poolingInterval, TimeUnit poolingUnit)
-1004throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1005return runJob(jobId, options, null, poolingInterval, poolingUnit);
-1006 }
-1007
-1008/**
-1009 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
-1010 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
-1011 * know if the execution is finished (or aborted) or is still running.
-1012 *
-1013 * @param jobId identifier of the job - mandatory
-1014 * @param options of the job - optional. See {@link OptionsBuilder}.
-1015 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
-1016 * {@link NodeFiltersBuilder}
-1017 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1018 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1019 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1020 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1021 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1022 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1023 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1024 * @see #triggerJob(String, Properties)
-1025 * @see #runJob(String, Properties, Properties, long, TimeUnit)
-1026 */
-1027publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters, long poolingInterval,
-1028 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1029 IllegalArgumentException {
-1030if (poolingInterval <= 0) {
-1031 poolingInterval = DEFAULT_POOLING_INTERVAL;
-1032 poolingUnit = DEFAULT_POOLING_UNIT;
-1033 }
-1034if (poolingUnit == null) {
-1035 poolingUnit = DEFAULT_POOLING_UNIT;
-1036 }
-1037
-1038RundeckExecution execution = triggerJob(jobId, options, nodeFilters);
-1039while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
-1040try {
-1041 Thread.sleep(poolingUnit.toMillis(poolingInterval));
-1042 } catch (InterruptedException e) {
-1043break;
-1044 }
-1045 execution = getExecution(execution.getId());
-1046 }
-1047return execution;
-1048 }
-1049
-1050/*
-1051 * Ad-hoc commands
-1052 */
-1053
-1054/**
-1055 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-1056 * The command will not be dispatched to nodes, but be executed on the RunDeck server.
-1057 *
-1058 * @param project name of the project - mandatory
-1059 * @param command to be executed - mandatory
-1060 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1061 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1062 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1063 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1064 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1065 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1066 * @see #runAdhocCommand(String, String)
-1067 */
-1068publicRundeckExecution triggerAdhocCommand(String project, String command) throws RundeckApiException,
-1069 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1070return triggerAdhocCommand(project, command, null);
-1071 }
-1072
-1073/**
-1074 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-1075 * The command will be dispatched to nodes, accordingly to the 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 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1081 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1082 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1083 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1084 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1085 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1086 * @see #runAdhocCommand(String, String, Properties)
-1087 */
-1088publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters)
-1089throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1090return triggerAdhocCommand(project, command, nodeFilters, null, null);
-1091 }
-1092
-1093/**
-1094 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
-1095 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1096 *
-1097 * @param project name of the project - mandatory
-1098 * @param command to be executed - mandatory
-1099 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1100 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1101 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1102 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1103 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1104 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1105 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1106 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1107 * @see #triggerAdhocCommand(String, String)
-1108 * @see #runAdhocCommand(String, String, Properties)
-1109 */
-1110publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters,
-1111 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
-1112 RundeckApiTokenException, IllegalArgumentException {
-1113 AssertUtil.notBlank(project, "project is mandatory to trigger an ad-hoc command !");
-1114 AssertUtil.notBlank(command, "command is mandatory to trigger an ad-hoc command !");
-1115RundeckExecution execution = newApiCall(this).get(newApiPathBuilder("/run/command").param("project", project)
-1116 .param("exec", command)
-1117 .param("nodeThreadcount",
-1118 nodeThreadcount)
-1119 .param("nodeKeepgoing",
-1120 nodeKeepgoing)
-1121 .nodeFilters(nodeFilters),
-1122newExecutionParser("result/execution"));
-1123// the first call just returns the ID of the execution, so we need another call to get a "real" execution
-1124return getExecution(execution.getId());
-1125 }
-1126
-1127/**
-1128 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1129 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1130 * running. The command will not be dispatched to nodes, but be executed on the RunDeck server.
-1131 *
-1132 * @param project name of the project - mandatory
-1133 * @param command to be executed - mandatory
-1134 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1135 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1136 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1137 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1138 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1139 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1140 * @see #triggerAdhocCommand(String, String)
-1141 */
-1142publicRundeckExecution runAdhocCommand(String project, String command) throws RundeckApiException,
-1143 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1144return runAdhocCommand(project, command, null);
-1145 }
-1146
-1147/**
-1148 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1149 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1150 * finished (or aborted) or is still running. The command will not be dispatched to nodes, but be executed on the
-1151 * RunDeck server.
-1152 *
-1153 * @param project name of the project - mandatory
-1154 * @param command to be executed - mandatory
-1155 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1156 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1157 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1158 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1159 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1160 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1161 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1162 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1163 * @see #triggerAdhocCommand(String, String)
-1164 */
-1165publicRundeckExecution runAdhocCommand(String project, String command, long poolingInterval, TimeUnit poolingUnit)
-1166throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1167return runAdhocCommand(project, command, null, poolingInterval, poolingUnit);
-1168 }
-1169
-1170/**
-1171 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1172 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1173 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1174 *
-1175 * @param project name of the project - mandatory
-1176 * @param command to be executed - mandatory
-1177 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1178 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1179 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1180 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1181 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1182 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1183 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1184 * @see #triggerAdhocCommand(String, String, Properties)
-1185 */
-1186publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters)
-1187throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1188return runAdhocCommand(project, command, nodeFilters, null, null);
-1189 }
-1190
-1191/**
-1192 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1193 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1194 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
-1195 * nodeFilters parameter.
-1196 *
-1197 * @param project name of the project - mandatory
-1198 * @param command to be executed - mandatory
-1199 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1200 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1201 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1202 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1203 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1204 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1205 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1206 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1207 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1208 * @see #triggerAdhocCommand(String, String, Properties)
-1209 */
-1210publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1211long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
-1212 RundeckApiTokenException, IllegalArgumentException {
-1213return runAdhocCommand(project, command, nodeFilters, null, null, poolingInterval, poolingUnit);
-1214 }
-1215
-1216/**
-1217 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1218 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1219 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1220 *
-1221 * @param project name of the project - mandatory
-1222 * @param command to be executed - mandatory
-1223 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1224 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1225 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1226 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1227 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1228 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1229 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1230 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1231 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
-1232 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1233 */
-1234publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1235 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
-1236 RundeckApiTokenException, IllegalArgumentException {
-1237return runAdhocCommand(project,
-1238 command,
-1239 nodeFilters,
-1240 nodeThreadcount,
-1241 nodeKeepgoing,
-1242 DEFAULT_POOLING_INTERVAL,
-1243 DEFAULT_POOLING_UNIT);
-1244 }
-1245
-1246/**
-1247 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1248 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1249 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
-1250 * nodeFilters parameter.
-1251 *
-1252 * @param project name of the project - mandatory
-1253 * @param command to be executed - mandatory
-1254 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1255 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1256 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1257 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1258 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1259 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1260 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1261 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1262 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1263 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
-1264 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
-1265 */
-1266publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
-1267 Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval, TimeUnit poolingUnit)
-1268throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1269if (poolingInterval <= 0) {
-1270 poolingInterval = DEFAULT_POOLING_INTERVAL;
-1271 poolingUnit = DEFAULT_POOLING_UNIT;
-1272 }
-1273if (poolingUnit == null) {
-1274 poolingUnit = DEFAULT_POOLING_UNIT;
-1275 }
-1276
-1277RundeckExecution execution = triggerAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing);
-1278while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
-1279try {
-1280 Thread.sleep(poolingUnit.toMillis(poolingInterval));
-1281 } catch (InterruptedException e) {
-1282break;
-1283 }
-1284 execution = getExecution(execution.getId());
-1285 }
-1286return execution;
-1287 }
-1288
-1289/*
-1290 * Ad-hoc scripts
-1291 */
-1292
-1293/**
-1294 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1295 * script will not be dispatched to nodes, but be executed on the RunDeck server.
-1296 *
-1297 * @param project name of the project - mandatory
-1298 * @param scriptFilename filename of the script to be executed - mandatory
-1299 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1300 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1301 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1302 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1303 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1304 * @throws IOException if we failed to read the file
-1305 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1306 * @see #runAdhocScript(String, String)
-1307 */
-1308publicRundeckExecution triggerAdhocScript(String project, String scriptFilename) throws RundeckApiException,
-1309 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1310return triggerAdhocScript(project, scriptFilename, null);
-1311 }
-1312
-1313/**
-1314 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1315 * script will not be dispatched to nodes, but be executed on the RunDeck server.
-1316 *
-1317 * @param project name of the project - mandatory
-1318 * @param scriptFilename filename of the script to be executed - mandatory
-1319 * @param options of the script - optional. See {@link OptionsBuilder}.
-1320 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1321 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1322 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1323 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1324 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1325 * @throws IOException if we failed to read the file
-1326 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1327 * @see #runAdhocScript(String, String, Properties)
-1328 */
-1329publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options)
-1330throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
-1331 IOException {
-1332return triggerAdhocScript(project, scriptFilename, options, null);
-1333 }
-1334
-1335/**
-1336 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1337 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1338 *
-1339 * @param project name of the project - mandatory
-1340 * @param scriptFilename filename of the script to be executed - mandatory
-1341 * @param options of the script - optional. See {@link OptionsBuilder}.
-1342 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1343 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1344 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1345 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1346 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1347 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1348 * @throws IOException if we failed to read the file
-1349 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1350 * @see #runAdhocScript(String, String, Properties, Properties)
-1351 */
-1352publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
-1353 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1354 IllegalArgumentException, IOException {
-1355return triggerAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
-1356 }
-1357
-1358/**
-1359 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1360 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1361 *
-1362 * @param project name of the project - mandatory
-1363 * @param scriptFilename filename of the script to be executed - mandatory
-1364 * @param options of the script - optional. See {@link OptionsBuilder}.
-1365 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1366 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1367 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1368 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1369 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1370 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1371 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1372 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1373 * @throws IOException if we failed to read the file
-1374 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
-1375 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1376 */
-1377publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
-1378 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
-1379 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1380 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to trigger an ad-hoc script !");
-1381 FileInputStream stream = null;
-1382try {
-1383 stream = FileUtils.openInputStream(new File(scriptFilename));
-1384return triggerAdhocScript(project, stream, options, nodeFilters, nodeThreadcount, nodeKeepgoing);
-1385 } finally {
-1386 IOUtils.closeQuietly(stream);
-1387 }
-1388 }
-1389
-1390/**
-1391 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1392 * script will not be dispatched to nodes, but be executed on the RunDeck server.
-1393 *
-1394 * @param project name of the project - mandatory
-1395 * @param script inputStream for reading the script to be executed - mandatory
-1396 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1397 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1398 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1399 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1400 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1401 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
-1402 * @see #runAdhocScript(String, InputStream)
-1403 */
-1404publicRundeckExecution triggerAdhocScript(String project, InputStream script) throws RundeckApiException,
-1405 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1406return triggerAdhocScript(project, script, null);
-1407 }
-1408
-1409/**
-1410 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1411 * script will not be dispatched to nodes, but be executed on the RunDeck server.
-1412 *
-1413 * @param project name of the project - mandatory
-1414 * @param script inputStream for reading the script to be executed - mandatory
-1415 * @param options of the script - optional. See {@link OptionsBuilder}.
-1416 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1417 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1418 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1419 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1420 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1421 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
-1422 * @see #runAdhocScript(String, InputStream, Properties)
-1423 */
-1424publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options)
-1425throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1426return triggerAdhocScript(project, script, options, null);
-1427 }
-1428
-1429/**
-1430 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1431 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1432 *
+901 * Get the definition of a single job, identified by the given ID
+902 *
+903 * @param jobId identifier of the job - mandatory
+904 * @return a {@link RundeckJob} instance - won't be null
+905 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+906 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+907 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+908 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+909 * @see #findJob(String, String, String)
+910 * @see #exportJob(String, String)
+911 */
+912publicRundeckJob getJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+913 RundeckApiTokenException, IllegalArgumentException {
+914 AssertUtil.notBlank(jobId, "jobId is mandatory to get the details of a job !");
+915returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId), newJobParser("joblist/job"));
+916 }
+917
+918/**
+919 * Delete a single job, identified by the given ID
+920 *
+921 * @param jobId identifier of the job - mandatory
+922 * @return the success message (note that in case of error, you'll get an exception)
+923 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+924 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+925 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+926 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+927 */
+928public String deleteJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+929 RundeckApiTokenException, IllegalArgumentException {
+930 AssertUtil.notBlank(jobId, "jobId is mandatory to delete a job !");
+931returnnewApiCall(this).delete(newApiPathBuilder("/job/", jobId), newStringParser("result/success/message"));
+932 }
+933/**
+934 * Delete multiple jobs, identified by the given IDs
+935 *
+936 * @param jobIds List of job IDS
+937 * @return the bulk delete result
+938 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+939 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+940 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+941 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+942 */
+943publicRundeckJobDeleteBulk deleteJobs(final List<String> jobIds) throws RundeckApiException, RundeckApiLoginException,
+944 RundeckApiTokenException, IllegalArgumentException {
+945if (null == jobIds || 0 == jobIds.size()) {
+946thrownew IllegalArgumentException("jobIds are mandatory to delete a job");
+947 }
+948returnnewApiCall(this).post(newApiPathBuilder("/jobs/delete").field("ids",jobIds),
+949newBulkDeleteParser("result/deleteJobs"));
+950 }
+951
+952/**
+953 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+954 * end of the job execution)
+955 *
+956 * @param jobId identifier of the job - mandatory
+957 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+958 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+959 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+960 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+961 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+962 * @see #triggerJob(String, Properties, Properties)
+963 * @see #runJob(String)
+964 * @deprecated use {@link #triggerJob(RunJob)}, this method will be removed in version 10 of this library
+965 */
+966publicRundeckExecution triggerJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+967 RundeckApiTokenException, IllegalArgumentException {
+968return triggerJob(jobId, null);
+969 }
+970
+971/**
+972 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+973 * end of the job execution)
+974 *
+975 * @param jobId identifier of the job - mandatory
+976 * @param options of the job - optional. See {@link OptionsBuilder}.
+977 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+978 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+979 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+980 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+981 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+982 * @see #triggerJob(String, Properties, Properties)
+983 * @see #runJob(String, Properties)
+984 * @deprecated use {@link #triggerJob(RunJob)}, this method will be removed in version 10 of this library
+985 */
+986publicRundeckExecution triggerJob(String jobId, Properties options) throws RundeckApiException,
+987 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+988return triggerJob(jobId, options, null);
+989 }
+990
+991/**
+992 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+993 * end of the job execution)
+994 *
+995 * @param jobId identifier of the job - mandatory
+996 * @param options of the job - optional. See {@link OptionsBuilder}.
+997 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+998 * {@link NodeFiltersBuilder}
+999 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1000 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1001 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1002 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1003 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1004 * @see #triggerJob(String)
+1005 * @see #runJob(String, Properties, Properties)
+1006 * @deprecated use {@link #triggerJob(RunJob)}, this method will be removed in version 10 of this library
+1007 */
+1008publicRundeckExecution triggerJob(String jobId, Properties options, Properties nodeFilters)
+1009throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1010return triggerJob(jobId, options, nodeFilters, null);
+1011 }
+1012/**
+1013 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+1014 * end of the job execution)
+1015 *
+1016 * @param jobId identifier of the job - mandatory
+1017 * @param options of the job - optional. See {@link OptionsBuilder}.
+1018 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+1019 * {@link NodeFiltersBuilder}
+1020 * @param asUser specify a user name to run the job as, must have 'runAs' permission
+1021 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1022 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1023 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1024 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1025 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1026 * @see #triggerJob(String)
+1027 * @see #runJob(String, Properties, Properties)
+1028 * @deprecated use {@link #triggerJob(RunJob)}, this method will be removed in version 10 of this library
+1029 */
+1030publicRundeckExecution triggerJob(String jobId, Properties options, Properties nodeFilters, String asUser)
+1031throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1032return triggerJob(RunJobBuilder.builder()
+1033 .setJobId(jobId)
+1034 .setOptions(options)
+1035 .setNodeFilters(nodeFilters)
+1036 .setAsUser(asUser)
+1037 .build());
+1038 }
+1039/**
+1040 * Trigger the execution of a RunDeck job (identified by the given ID), and return immediately (without waiting the
+1041 * end of the job execution)
+1042 *
+1043 * @param jobRun the RunJob, see {@link RunJobBuilder}
+1044 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1045 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1046 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1047 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1048 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1049 * @see #triggerJob(String)
+1050 * @see #runJob(String, Properties, Properties)
+1051 */
+1052publicRundeckExecution triggerJob(finalRunJob jobRun)
+1053throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1054 AssertUtil.notBlank(jobRun.getJobId(), "jobId is mandatory to trigger a job !");
+1055ApiPathBuilder apiPath = newApiPathBuilder("/job/", jobRun.getJobId(), "/run").param("argString",
+1056 ParametersUtil.generateArgString(jobRun.getOptions()))
+1057 .nodeFilters(jobRun.getNodeFilters());
+1058if(null!=jobRun.getAsUser()) {
+1059 apiPath.param("asUser", jobRun.getAsUser());
+1060 }
+1061returnnewApiCall(this).get(apiPath, newExecutionParser("result/executions/execution"));
+1062 }
+1063
+1064/**
+1065 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1066 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+1067 * aborted) or is still running.
+1068 *
+1069 * @param jobId identifier of the job - mandatory
+1070 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1071 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1072 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1073 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1074 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1075 * @see #triggerJob(String)
+1076 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1077 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)},
+1078 * this method will be removed in version 10 of this library
+1079 */
+1080publicRundeckExecution runJob(String jobId) throws RundeckApiException, RundeckApiLoginException,
+1081 RundeckApiTokenException, IllegalArgumentException {
+1082return runJob(jobId, null);
+1083 }
+1084
+1085/**
+1086 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1087 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+1088 * aborted) or is still running.
+1089 *
+1090 * @param jobId identifier of the job - mandatory
+1091 * @param options of the job - optional. See {@link OptionsBuilder}.
+1092 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1093 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1094 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1095 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1096 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1097 * @see #triggerJob(String, Properties)
+1098 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1099 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)},
+1100 * this method will be removed in version 10 of this library
+1101 */
+1102publicRundeckExecution runJob(String jobId, Properties options) throws RundeckApiException,
+1103 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1104return runJob(jobId, options, null);
+1105 }
+1106
+1107/**
+1108 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1109 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+1110 * aborted) or is still running.
+1111 *
+1112 * @param jobId identifier of the job - mandatory
+1113 * @param options of the job - optional. See {@link OptionsBuilder}.
+1114 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+1115 * {@link NodeFiltersBuilder}
+1116 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1117 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1118 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1119 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1120 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1121 * @see #triggerJob(String, Properties, Properties)
+1122 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1123 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)},
+1124 * this method will be removed in version 10 of this library
+1125 */
+1126publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters)
+1127throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1128return runJob(jobId, options, nodeFilters, DEFAULT_POOLING_INTERVAL, DEFAULT_POOLING_UNIT);
+1129 }
+1130
+1131/**
+1132 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1133 * We will poll the RunDeck server at regular interval (every 5 seconds) to know if the execution is finished (or
+1134 * aborted) or is still running.
+1135 *
+1136 * @param runJob the RunJob, see {@link RunJobBuilder}
+1137 *
+1138 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1139 *
+1140 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1141 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1142 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1143 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1144 * @see #triggerJob(RunJob)
+1145 * @see #runJob(RunJob, long, TimeUnit)
+1146 */
+1147publicRundeckExecution runJob(finalRunJob runJob) throws RundeckApiException, RundeckApiLoginException,
+1148 RundeckApiTokenException, IllegalArgumentException {
+1149return runJob(runJob, DEFAULT_POOLING_INTERVAL, DEFAULT_POOLING_UNIT);
+1150 }
+1151/**
+1152 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1153 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+1154 * know if the execution is finished (or aborted) or is still running.
+1155 *
+1156 * @param jobId identifier of the job - mandatory
+1157 * @param options of the job - optional. See {@link OptionsBuilder}.
+1158 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1159 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1160 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1161 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1162 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1163 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1164 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1165 * @see #triggerJob(String, Properties)
+1166 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1167 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)},
+1168 * this method will be removed in version 10 of this library
+1169 */
+1170publicRundeckExecution runJob(String jobId, Properties options, long poolingInterval, TimeUnit poolingUnit)
+1171throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1172return runJob(jobId, options, null, poolingInterval, poolingUnit);
+1173 }
+1174
+1175/**
+1176 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1177 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+1178 * know if the execution is finished (or aborted) or is still running.
+1179 *
+1180 * @param jobId identifier of the job - mandatory
+1181 * @param options of the job - optional. See {@link OptionsBuilder}.
+1182 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+1183 * {@link NodeFiltersBuilder}
+1184 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1185 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1186 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1187 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1188 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1189 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1190 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1191 * @see #triggerJob(String, Properties)
+1192 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1193 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)},
+1194 * this method will be removed in version 10 of this library
+1195 */
+1196publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters, long poolingInterval,
+1197 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+1198 IllegalArgumentException {
+1199return runJob(jobId, options, nodeFilters, null, poolingInterval, poolingUnit);
+1200 }
+1201/**
+1202 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1203 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+1204 * know if the execution is finished (or aborted) or is still running.
+1205 *
+1206 * @param jobId identifier of the job - mandatory
+1207 * @param options of the job - optional. See {@link OptionsBuilder}.
+1208 * @param nodeFilters for overriding the nodes on which the job will be executed - optional. See
+1209 * {@link NodeFiltersBuilder}
+1210 * @param asUser specify a user name to run the job as, must have 'runAs' permission
+1211 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1212 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1213 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1214 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1215 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1216 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1217 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1218 * @see #triggerJob(String, Properties)
+1219 * @see #runJob(String, Properties, Properties, long, TimeUnit)
+1220 * @deprecated use {@link #runJob(RunJob, long, java.util.concurrent.TimeUnit)}, this method will be removed in version 10 of this library
+1221 */
+1222publicRundeckExecution runJob(String jobId, Properties options, Properties nodeFilters, String asUser, long poolingInterval,
+1223 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+1224 IllegalArgumentException {
+1225return runJob(RunJobBuilder.builder()
+1226 .setJobId(jobId)
+1227 .setOptions(options)
+1228 .setNodeFilters(nodeFilters)
+1229 .setAsUser(asUser)
+1230 .build(), poolingInterval, poolingUnit);
+1231 }
+1232
+1233/**
+1234 * Run a RunDeck job (identified by the given ID), and wait until its execution is finished (or aborted) to return.
+1235 * We will poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to
+1236 * know if the execution is finished (or aborted) or is still running.
+1237 *
+1238 * @param jobRun the RunJob, see {@link RunJobBuilder}
+1239 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1240 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1241 *
+1242 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1243 *
+1244 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+1245 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1246 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1247 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+1248 * @see #triggerJob(RunJob)
+1249 */
+1250publicRundeckExecution runJob(finalRunJob jobRun, long poolingInterval,
+1251 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+1252 IllegalArgumentException {
+1253
+1254if (poolingInterval <= 0) {
+1255 poolingInterval = DEFAULT_POOLING_INTERVAL;
+1256 poolingUnit = DEFAULT_POOLING_UNIT;
+1257 }
+1258if (poolingUnit == null) {
+1259 poolingUnit = DEFAULT_POOLING_UNIT;
+1260 }
+1261
+1262RundeckExecution execution = triggerJob(jobRun);
+1263while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+1264try {
+1265 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+1266 } catch (InterruptedException e) {
+1267break;
+1268 }
+1269 execution = getExecution(execution.getId());
+1270 }
+1271return execution;
+1272 }
+1273
+1274/*
+1275 * Ad-hoc commands
+1276 */
+1277
+1278/**
+1279 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+1280 * The command will not be dispatched to nodes, but be executed on the RunDeck server.
+1281 *
+1282 * @param project name of the project - mandatory
+1283 * @param command to be executed - mandatory
+1284 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1285 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1286 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1287 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1288 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1289 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1290 * @see #runAdhocCommand(String, String)
+1291 * @deprecated use {@link #triggerAdhocCommand(RunAdhocCommand)}, will be removed in version 10 of this library
+1292 */
+1293publicRundeckExecution triggerAdhocCommand(String project, String command) throws RundeckApiException,
+1294 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1295return triggerAdhocCommand(project, command, null);
+1296 }
+1297
+1298/**
+1299 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+1300 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1301 *
+1302 * @param project name of the project - mandatory
+1303 * @param command to be executed - mandatory
+1304 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1305 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1306 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1307 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1308 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1309 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1310 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1311 * @see #runAdhocCommand(String, String, Properties)
+1312 * @deprecated use {@link #triggerAdhocCommand(RunAdhocCommand)}, will be removed in version 10 of this library
+1313 */
+1314publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters)
+1315throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1316return triggerAdhocCommand(project, command, nodeFilters, null, null);
+1317 }
+1318
+1319/**
+1320 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+1321 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1322 *
+1323 * @param project name of the project - mandatory
+1324 * @param command to be executed - mandatory
+1325 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1326 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1327 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1328 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1329 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1330 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1331 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1332 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1333 * @see #triggerAdhocCommand(String, String)
+1334 * @see #runAdhocCommand(String, String, Properties)
+1335 * @deprecated use {@link #triggerAdhocCommand(RunAdhocCommand)}, will be removed in version 10 of this library
+1336 */
+1337publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters,
+1338 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
+1339 RundeckApiTokenException, IllegalArgumentException {
+1340return triggerAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing, null);
+1341 }
+1342/**
+1343 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+1344 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1345 *
+1346 * @param project name of the project - mandatory
+1347 * @param command to be executed - mandatory
+1348 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1349 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1350 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1351 * @param asUser specify a user name to run the job as, must have 'runAs' permission
+1352 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1353 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1354 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1355 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1356 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1357 * @see #triggerAdhocCommand(String, String)
+1358 * @see #runAdhocCommand(String, String, Properties)
+1359 * @deprecated use {@link #triggerAdhocCommand(RunAdhocCommand)}, will be removed in version 10 of this library
+1360 */
+1361publicRundeckExecution triggerAdhocCommand(String project, String command, Properties nodeFilters,
+1362 Integer nodeThreadcount, Boolean nodeKeepgoing, String asUser) throws RundeckApiException, RundeckApiLoginException,
+1363 RundeckApiTokenException, IllegalArgumentException {
+1364return triggerAdhocCommand(RunAdhocCommandBuilder.builder()
+1365 .setProject(project)
+1366 .setCommand(command)
+1367 .setNodeFilters(nodeFilters)
+1368 .setNodeThreadcount(nodeThreadcount)
+1369 .setNodeKeepgoing(nodeKeepgoing)
+1370 .setAsUser(asUser)
+1371 .build());
+1372 }
+1373/**
+1374 * Trigger the execution of an ad-hoc command, and return immediately (without waiting the end of the execution).
+1375 * The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1376 *
+1377 * @param command the RunAdhocCommand. Project and command are mandatory, see {@link RunAdhocCommandBuilder}
+1378 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1379 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1380 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1381 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1382 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1383 * @see #triggerAdhocCommand(String, String)
+1384 * @see #runAdhocCommand(String, String, Properties)
+1385 */
+1386publicRundeckExecution triggerAdhocCommand(RunAdhocCommand command) throws RundeckApiException, RundeckApiLoginException,
+1387 RundeckApiTokenException, IllegalArgumentException {
+1388 AssertUtil.notBlank(command.getProject(), "project is mandatory to trigger an ad-hoc command !");
+1389 AssertUtil.notBlank(command.getCommand(), "command is mandatory to trigger an ad-hoc command !");
+1390ApiPathBuilder apiPath = newApiPathBuilder("/run/command").param("project", command.getProject())
+1391 .param("exec", command.getCommand())
+1392 .param("nodeThreadcount",
+1393 command.getNodeThreadcount())
+1394 .param("nodeKeepgoing",
+1395 command.getNodeKeepgoing())
+1396 .nodeFilters(command.getNodeFilters());
+1397if(null!= command.getAsUser()) {
+1398 apiPath.param("asUser", command.getAsUser());
+1399 }
+1400RundeckExecution execution = newApiCall(this).get(apiPath, newExecutionParser("result/execution"));
+1401// the first call just returns the ID of the execution, so we need another call to get a "real" execution
+1402return getExecution(execution.getId());
+1403 }
+1404
+1405/**
+1406 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1407 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1408 * running. The command will not be dispatched to nodes, but be executed on the RunDeck server.
+1409 *
+1410 * @param project name of the project - mandatory
+1411 * @param command to be executed - mandatory
+1412 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1413 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1414 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1415 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1416 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1417 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1418 * @see #triggerAdhocCommand(String, String)
+1419 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand)}, this method will
+1420 * be removed in version 10 of this library
+1421 */
+1422publicRundeckExecution runAdhocCommand(String project, String command) throws RundeckApiException,
+1423 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1424return runAdhocCommand(project, command, null);
+1425 }
+1426
+1427/**
+1428 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1429 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1430 * finished (or aborted) or is still running. The command will not be dispatched to nodes, but be executed on the
+1431 * RunDeck server.
+1432 *1433 * @param project name of the project - mandatory
-1434 * @param script inputStream for reading the script to be executed - mandatory
-1435 * @param options of the script - optional. See {@link OptionsBuilder}.
-1436 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1437 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1434 * @param command to be executed - mandatory
+1435 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1436 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1437 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null1438 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)1439 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)1440 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1441 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1442 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
-1443 * @see #runAdhocScript(String, InputStream, Properties, Properties)
-1444 */
-1445publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
-1446 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1447 IllegalArgumentException {
-1448return triggerAdhocScript(project, script, options, nodeFilters, null, null);
-1449 }
-1450
-1451/**
-1452 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
-1453 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1454 *
-1455 * @param project name of the project - mandatory
-1456 * @param script inputStream for reading the script to be executed - mandatory
-1457 * @param options of the script - optional. See {@link OptionsBuilder}.
-1458 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
-1459 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1460 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1461 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
-1462 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1463 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1464 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1465 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1466 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1467 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1468 */
-1469publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
-1470 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
-1471 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1472 AssertUtil.notBlank(project, "project is mandatory to trigger an ad-hoc script !");
-1473 AssertUtil.notNull(script, "script is mandatory to trigger an ad-hoc script !");
-1474RundeckExecution execution = newApiCall(this).post(newApiPathBuilder("/run/script").param("project", project)
-1475 .attach("scriptFile",
-1476 script)
-1477 .param("argString",
-1478 ParametersUtil.generateArgString(options))
-1479 .param("nodeThreadcount",
-1480 nodeThreadcount)
-1481 .param("nodeKeepgoing",
-1482 nodeKeepgoing)
-1483 .nodeFilters(nodeFilters),
-1484newExecutionParser("result/execution"));
-1485// the first call just returns the ID of the execution, so we need another call to get a "real" execution
-1486return getExecution(execution.getId());
-1487 }
-1488
-1489/**
-1490 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1491 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1492 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
-1493 *
-1494 * @param project name of the project - mandatory
-1495 * @param scriptFilename filename of the script to be executed - mandatory
-1496 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1497 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1498 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1499 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1500 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1501 * @throws IOException if we failed to read the file
-1502 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1503 * @see #triggerAdhocScript(String, String)
-1504 */
-1505publicRundeckExecution runAdhocScript(String project, String scriptFilename) throws RundeckApiException,
-1506 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1507return runAdhocScript(project, scriptFilename, null);
-1508 }
-1509
-1510/**
-1511 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1512 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1513 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
-1514 * RunDeck server.
-1515 *
-1516 * @param project name of the project - mandatory
-1517 * @param scriptFilename filename of the script to be executed - mandatory
-1518 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1519 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1520 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1521 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1522 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1523 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1524 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1525 * @throws IOException if we failed to read the file
-1526 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1527 * @see #triggerAdhocScript(String, String)
-1528 */
-1529publicRundeckExecution runAdhocScript(String project, String scriptFilename, long poolingInterval,
-1530 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1531 IllegalArgumentException, IOException {
-1532return runAdhocScript(project, scriptFilename, null, poolingInterval, poolingUnit);
-1533 }
-1534
-1535/**
-1536 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1537 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1538 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
-1539 *
-1540 * @param project name of the project - mandatory
-1541 * @param scriptFilename filename of the script to be executed - mandatory
-1542 * @param options of the script - optional. See {@link OptionsBuilder}.
-1543 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1544 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1545 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1546 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1547 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1548 * @throws IOException if we failed to read the file
-1549 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1550 * @see #triggerAdhocScript(String, String, Properties)
-1551 */
-1552publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options)
-1553throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
-1554 IOException {
-1555return runAdhocScript(project, scriptFilename, options, null);
-1556 }
-1557
-1558/**
-1559 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1560 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1561 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
-1562 * RunDeck server.
-1563 *
-1564 * @param project name of the project - mandatory
-1565 * @param scriptFilename filename of the script to be executed - mandatory
-1566 * @param options of the script - optional. See {@link OptionsBuilder}.
-1567 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1568 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-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 fails (in case of login-based authentication)
-1572 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1573 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1574 * @throws IOException if we failed to read the file
-1575 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1576 * @see #triggerAdhocScript(String, String, Properties)
-1577 */
-1578publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
-1579long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
-1580 RundeckApiTokenException, IllegalArgumentException, IOException {
-1581return runAdhocScript(project, scriptFilename, options, null, poolingInterval, poolingUnit);
-1582 }
-1583
-1584/**
-1585 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1586 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1587 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1588 *
-1589 * @param project name of the project - mandatory
-1590 * @param scriptFilename filename of the script to be executed - mandatory
-1591 * @param options of the script - optional. See {@link OptionsBuilder}.
-1592 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-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 fails (in case of login-based authentication)
-1596 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1597 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1598 * @throws IOException if we failed to read the file
-1599 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1600 * @see #triggerAdhocScript(String, String, Properties, Properties)
-1601 */
-1602publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
-1603 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1604 IllegalArgumentException, IOException {
-1605return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
-1606 }
-1607
-1608/**
-1609 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1610 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1611 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
-1612 * parameter.
-1613 *
-1614 * @param project name of the project - mandatory
-1615 * @param scriptFilename filename of the script to be executed - mandatory
-1616 * @param options of the script - optional. See {@link OptionsBuilder}.
-1617 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1618 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1619 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1620 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1621 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1622 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1623 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1624 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1625 * @throws IOException if we failed to read the file
-1626 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1627 * @see #triggerAdhocScript(String, String, Properties, Properties)
-1628 */
-1629publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
-1630 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
-1631 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1632return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null, poolingInterval, poolingUnit);
-1633 }
-1634
-1635/**
-1636 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1637 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1638 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1639 *
-1640 * @param project name of the project - mandatory
-1641 * @param scriptFilename filename of the script to be executed - mandatory
-1642 * @param options of the script - optional. See {@link OptionsBuilder}.
-1643 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1644 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1645 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1646 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1647 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1648 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1649 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1650 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1651 * @throws IOException if we failed to read the file
-1652 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1653 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1654 */
-1655publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
-1656 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
-1657 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1658return runAdhocScript(project,
-1659 scriptFilename,
-1660 options,
-1661 nodeFilters,
-1662 nodeThreadcount,
-1663 nodeKeepgoing,
-1664 DEFAULT_POOLING_INTERVAL,
-1665 DEFAULT_POOLING_UNIT);
-1666 }
-1667
-1668/**
-1669 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1670 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1671 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
-1672 * parameter.
-1673 *
-1674 * @param project name of the project - mandatory
-1675 * @param scriptFilename filename of the script to be executed - mandatory
-1676 * @param options of the script - optional. See {@link OptionsBuilder}.
-1677 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1678 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1679 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1680 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1681 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1682 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1683 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1684 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1685 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1686 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
-1687 * @throws IOException if we failed to read the file
-1688 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1689 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
-1690 */
-1691publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
-1692 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
-1693 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1694 IllegalArgumentException, IOException {
-1695 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to run an ad-hoc script !");
-1696 FileInputStream stream = null;
-1697try {
-1698 stream = FileUtils.openInputStream(new File(scriptFilename));
-1699return runAdhocScript(project,
-1700 stream,
-1701 options,
-1702 nodeFilters,
-1703 nodeThreadcount,
-1704 nodeKeepgoing,
-1705 poolingInterval,
-1706 poolingUnit);
-1707 } finally {
-1708 IOUtils.closeQuietly(stream);
-1709 }
-1710 }
-1711
-1712/**
-1713 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1714 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1715 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
-1716 *
-1717 * @param project name of the project - mandatory
-1718 * @param script inputStream for reading the script to be executed - mandatory
-1719 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1720 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1721 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1722 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1723 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1724 * @throws IOException if we failed to read the file
-1725 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1726 * @see #triggerAdhocScript(String, InputStream)
-1727 */
-1728publicRundeckExecution runAdhocScript(String project, InputStream script) throws RundeckApiException,
-1729 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1730return runAdhocScript(project, script, null);
-1731 }
-1732
-1733/**
-1734 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1735 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1736 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
-1737 * RunDeck server.
-1738 *
-1739 * @param project name of the project - mandatory
-1740 * @param script inputStream for reading the script to be executed - mandatory
-1741 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1742 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1743 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1744 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1745 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1746 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1747 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1748 * @throws IOException if we failed to read the file
-1749 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1750 * @see #triggerAdhocScript(String, InputStream)
-1751 */
-1752publicRundeckExecution runAdhocScript(String project, InputStream script, long poolingInterval,
-1753 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1754 IllegalArgumentException, IOException {
-1755return runAdhocScript(project, script, null, poolingInterval, poolingUnit);
-1756 }
-1757
+1441 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1442 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1443 * @see #triggerAdhocCommand(String, String)
+1444 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand, long, java.util.concurrent.TimeUnit)}, this method will
+1445 * be removed in version 10 of this library
+1446 */
+1447publicRundeckExecution runAdhocCommand(String project, String command, long poolingInterval, TimeUnit poolingUnit)
+1448throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1449return runAdhocCommand(project, command, null, poolingInterval, poolingUnit);
+1450 }
+1451
+1452/**
+1453 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1454 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1455 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1456 *
+1457 * @param project name of the project - mandatory
+1458 * @param command to be executed - mandatory
+1459 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1460 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1461 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1462 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1463 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1464 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1465 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1466 * @see #triggerAdhocCommand(String, String, Properties)
+1467 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand)}, this method will
+1468 * be removed in version 10 of this library
+1469 */
+1470publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters)
+1471throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1472return runAdhocCommand(project, command, nodeFilters, null, null);
+1473 }
+1474
+1475/**
+1476 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1477 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1478 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1479 * nodeFilters parameter.
+1480 *
+1481 * @param project name of the project - mandatory
+1482 * @param command to be executed - mandatory
+1483 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1484 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1485 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1486 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1487 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1488 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1489 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1490 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1491 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1492 * @see #triggerAdhocCommand(String, String, Properties)
+1493 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand, long, java.util.concurrent.TimeUnit)}, this method will
+1494 * be removed in version 10 of this library
+1495 */
+1496publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1497long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+1498 RundeckApiTokenException, IllegalArgumentException {
+1499return runAdhocCommand(project, command, nodeFilters, null, null, poolingInterval, poolingUnit);
+1500 }
+1501
+1502/**
+1503 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1504 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1505 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1506 *
+1507 * @param project name of the project - mandatory
+1508 * @param command to be executed - mandatory
+1509 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1510 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1511 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1512 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1513 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1514 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1515 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1516 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1517 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1518 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1519 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand)}, this method will
+1520 * be removed in version 10 of this library
+1521 */
+1522publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1523 Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException, RundeckApiLoginException,
+1524 RundeckApiTokenException, IllegalArgumentException {
+1525return runAdhocCommand(project,
+1526 command,
+1527 nodeFilters,
+1528 nodeThreadcount,
+1529 nodeKeepgoing,
+1530 DEFAULT_POOLING_INTERVAL,
+1531 DEFAULT_POOLING_UNIT);
+1532 }
+1533
+1534/**
+1535 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1536 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+1537 * running. The command will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1538 *
+1539 * @param command the RunAdhocCommand, see {@link RunAdhocCommandBuilder}
+1540 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1541 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1542 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1543 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1544 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1545 * @see #runAdhocCommand(String, String, Properties, Integer, Boolean, long, TimeUnit)
+1546 * @see #triggerAdhocCommand(RunAdhocCommand)
+1547 */
+1548publicRundeckExecution runAdhocCommand(RunAdhocCommand command) throws RundeckApiException, RundeckApiLoginException,
+1549 RundeckApiTokenException, IllegalArgumentException {
+1550return runAdhocCommand(command,
+1551 DEFAULT_POOLING_INTERVAL,
+1552 DEFAULT_POOLING_UNIT);
+1553 }
+1554
+1555/**
+1556 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1557 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1558 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1559 * nodeFilters parameter.
+1560 *
+1561 * @param project name of the project - mandatory
+1562 * @param command to be executed - mandatory
+1563 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1564 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1565 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1566 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1567 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1568 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1569 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1570 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1571 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1572 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1573 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1574 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand, long, java.util.concurrent.TimeUnit)}, this method will
+1575 * be removed in version 10 of this library
+1576 */
+1577publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1578 Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval, TimeUnit poolingUnit)
+1579throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1580return runAdhocCommand(project, command, nodeFilters, nodeThreadcount, nodeKeepgoing, null, poolingInterval, poolingUnit);
+1581 }
+1582
+1583/**
+1584 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1585 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1586 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1587 * nodeFilters parameter.
+1588 *
+1589 * @param project name of the project - mandatory
+1590 * @param command to be executed - mandatory
+1591 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1592 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1593 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1594 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1595 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1596 *
+1597 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1598 *
+1599 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1600 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1601 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1602 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1603 * @see #triggerAdhocCommand(String, String, Properties, Integer, Boolean)
+1604 * @deprecated use {@link #runAdhocCommand(RunAdhocCommand, long, java.util.concurrent.TimeUnit)}, this method will
+1605 * be removed in version 10 of this library
+1606 */
+1607publicRundeckExecution runAdhocCommand(String project, String command, Properties nodeFilters,
+1608 Integer nodeThreadcount, Boolean nodeKeepgoing, String asUser, long poolingInterval, TimeUnit poolingUnit)
+1609throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1610return runAdhocCommand(RunAdhocCommandBuilder.builder()
+1611 .setProject(project)
+1612 .setCommand(command)
+1613 .setNodeFilters(nodeFilters)
+1614 .setNodeThreadcount(nodeThreadcount)
+1615 .setNodeKeepgoing(nodeKeepgoing)
+1616 .setAsUser(asUser)
+1617 .build(), poolingInterval, poolingUnit);
+1618 }
+1619/**
+1620 * Run an ad-hoc command, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+1621 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+1622 * finished (or aborted) or is still running. The command will be dispatched to nodes, accordingly to the
+1623 * nodeFilters parameter.
+1624 *
+1625 * @param command the RunAdhocCommand, see {@link RunAdhocCommandBuilder}
+1626 * @param poolingInterval for checking the status of the execution. Must be > 0.
+1627 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+1628 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+1629 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1630 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1631 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1632 * @throws IllegalArgumentException if the project or command is blank (null, empty or whitespace)
+1633 * @see #triggerAdhocCommand(RunAdhocCommand)
+1634 */
+1635publicRundeckExecution runAdhocCommand(RunAdhocCommand command, long poolingInterval, TimeUnit poolingUnit)
+1636throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1637if (poolingInterval <= 0) {
+1638 poolingInterval = DEFAULT_POOLING_INTERVAL;
+1639 poolingUnit = DEFAULT_POOLING_UNIT;
+1640 }
+1641if (poolingUnit == null) {
+1642 poolingUnit = DEFAULT_POOLING_UNIT;
+1643 }
+1644
+1645RundeckExecution execution = triggerAdhocCommand(command);
+1646while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+1647try {
+1648 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+1649 } catch (InterruptedException e) {
+1650break;
+1651 }
+1652 execution = getExecution(execution.getId());
+1653 }
+1654return execution;
+1655 }
+1656
+1657/*
+1658 * Ad-hoc scripts
+1659 */
+1660
+1661/**
+1662 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1663 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1664 *
+1665 * @param project name of the project - mandatory
+1666 * @param scriptFilename filename of the script to be executed - mandatory
+1667 * @return a {@link RundeckExecution} instance for the newly created (and running) 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 fails (in case of login-based authentication)
+1670 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1671 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1672 * @throws IOException if we failed to read the file
+1673 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1674 * @see #runAdhocScript(String, String)
+1675 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1676 * removed in version 10 of this library
+1677 */
+1678publicRundeckExecution triggerAdhocScript(String project, String scriptFilename) throws RundeckApiException,
+1679 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+1680return triggerAdhocScript(project, scriptFilename, null);
+1681 }
+1682
+1683/**
+1684 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1685 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1686 *
+1687 * @param project name of the project - mandatory
+1688 * @param scriptFilename filename of the script to be executed - mandatory
+1689 * @param options of the script - optional. See {@link OptionsBuilder}.
+1690 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1691 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1692 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1693 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1694 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1695 * @throws IOException if we failed to read the file
+1696 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1697 * @see #runAdhocScript(String, String, Properties)
+1698 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1699 * removed in version 10 of this library
+1700 */
+1701publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options)
+1702throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
+1703 IOException {
+1704return triggerAdhocScript(project, scriptFilename, options, null);
+1705 }
+1706
+1707/**
+1708 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1709 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1710 *
+1711 * @param project name of the project - mandatory
+1712 * @param scriptFilename filename of the script to be executed - mandatory
+1713 * @param options of the script - optional. See {@link OptionsBuilder}.
+1714 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1715 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1716 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1717 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1718 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1719 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1720 * @throws IOException if we failed to read the file
+1721 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1722 * @see #runAdhocScript(String, String, Properties, Properties)
+1723 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1724 * removed in version 10 of this library
+1725 */
+1726publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
+1727 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+1728 IllegalArgumentException, IOException {
+1729return triggerAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
+1730 }
+1731
+1732/**
+1733 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1734 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1735 *
+1736 * @param project name of the project - mandatory
+1737 * @param scriptFilename filename of the script to be executed - mandatory
+1738 * @param options of the script - optional. See {@link OptionsBuilder}.
+1739 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1740 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1741 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1742 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1743 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1744 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1745 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1746 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1747 * @throws IOException if we failed to read the file
+1748 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1749 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1750 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1751 * removed in version 10 of this library
+1752 */
+1753publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
+1754 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1755 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+1756return triggerAdhocScript(project, scriptFilename, options, nodeFilters, nodeThreadcount, nodeKeepgoing, null);
+1757 }
1758/**
-1759 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1760 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1761 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
-1762 *
-1763 * @param project name of the project - mandatory
-1764 * @param script inputStream for reading the script to be executed - mandatory
-1765 * @param options of the script - optional. See {@link OptionsBuilder}.
-1766 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1767 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1768 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1769 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1770 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1771 * @throws IOException if we failed to read the file
-1772 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1773 * @see #triggerAdhocScript(String, InputStream, Properties)
-1774 */
-1775publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options)
-1776throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
-1777 IOException {
-1778return runAdhocScript(project, script, options, null);
-1779 }
-1780
-1781/**
-1782 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1783 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1784 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
-1785 * RunDeck server.
-1786 *
-1787 * @param project name of the project - mandatory
-1788 * @param script inputStream for reading the script to be executed - mandatory
-1789 * @param options of the script - optional. See {@link OptionsBuilder}.
-1790 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1791 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1792 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1793 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1794 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1795 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1796 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1797 * @throws IOException if we failed to read the file
-1798 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1799 * @see #triggerAdhocScript(String, InputStream, Properties)
-1800 */
-1801publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
-1802long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
-1803 RundeckApiTokenException, IllegalArgumentException, IOException {
-1804return runAdhocScript(project, script, options, null, poolingInterval, poolingUnit);
-1805 }
-1806
-1807/**
-1808 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1809 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1810 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1811 *
-1812 * @param project name of the project - mandatory
-1813 * @param script inputStream for reading the script to be executed - mandatory
-1814 * @param options of the script - optional. See {@link OptionsBuilder}.
-1815 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1816 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1817 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1818 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1819 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1820 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1821 * @throws IOException if we failed to read the file
-1822 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1823 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
-1824 */
-1825publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
-1826 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1827 IllegalArgumentException, IOException {
-1828return runAdhocScript(project, script, options, nodeFilters, null, null);
-1829 }
-1830
-1831/**
-1832 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1833 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1834 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
-1835 * parameter.
-1836 *
-1837 * @param project name of the project - mandatory
-1838 * @param script inputStream for reading the script to be executed - mandatory
-1839 * @param options of the script - optional. See {@link OptionsBuilder}.
-1840 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1841 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1842 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1843 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1844 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1845 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1846 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1847 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1848 * @throws IOException if we failed to read the file
-1849 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1850 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
-1851 */
-1852publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
-1853 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
-1854 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1855return runAdhocScript(project, script, options, nodeFilters, null, null, poolingInterval, poolingUnit);
-1856 }
-1857
-1858/**
-1859 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1860 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
-1861 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
-1862 *
-1863 * @param project name of the project - mandatory
-1864 * @param script inputStream for reading the script to be executed - mandatory
-1865 * @param options of the script - optional. See {@link OptionsBuilder}.
-1866 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1867 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1868 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1869 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1870 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1871 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1872 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1873 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1874 * @throws IOException if we failed to read the file
-1875 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1876 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
-1877 */
-1878publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
-1879 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
-1880 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
-1881return runAdhocScript(project,
-1882 script,
-1883 options,
-1884 nodeFilters,
-1885 nodeThreadcount,
-1886 nodeKeepgoing,
-1887 DEFAULT_POOLING_INTERVAL,
-1888 DEFAULT_POOLING_UNIT);
-1889 }
-1890
-1891/**
-1892 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
-1893 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
-1894 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
-1895 * parameter.
-1896 *
-1897 * @param project name of the project - mandatory
-1898 * @param script inputStream for reading the script to be executed - mandatory
-1899 * @param options of the script - optional. See {@link OptionsBuilder}.
-1900 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
-1901 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
-1902 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
-1903 * @param poolingInterval for checking the status of the execution. Must be > 0.
-1904 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
-1905 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
-1906 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1907 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1908 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1909 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
-1910 * @throws IOException if we failed to read the file
-1911 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
-1912 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1759 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1760 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1761 *
+1762 * @param project name of the project - mandatory
+1763 * @param scriptFilename filename of the script to be executed - mandatory
+1764 * @param options of the script - optional. See {@link OptionsBuilder}.
+1765 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1766 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1767 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1768 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1769 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1770 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1771 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1772 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1773 * @throws IOException if we failed to read the file
+1774 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1775 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1776 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1777 * removed in version 10 of this library
+1778 */
+1779publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, Properties options,
+1780 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing,String asUser) throws RundeckApiException,
+1781 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+1782return triggerAdhocScript(project, scriptFilename, ParametersUtil.generateArgString(options), nodeFilters,
+1783 nodeThreadcount, nodeKeepgoing, asUser);
+1784 }
+1785/**
+1786 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1787 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1788 *
+1789 * @param project name of the project - mandatory
+1790 * @param scriptFilename filename of the script to be executed - mandatory
+1791 * @param argString arguments of the script - optional.
+1792 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1793 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1794 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1795 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1796 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1797 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1798 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1799 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+1800 * @throws IOException if we failed to read the file
+1801 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1802 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1803 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1804 * removed in version 10 of this library
+1805 */
+1806publicRundeckExecution triggerAdhocScript(String project, String scriptFilename, String argString,
+1807 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing,String asUser) throws RundeckApiException,
+1808 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+1809 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to trigger an ad-hoc script !");
+1810 FileInputStream stream = null;
+1811try {
+1812 stream = FileUtils.openInputStream(new File(scriptFilename));
+1813return triggerAdhocScript(RunAdhocScriptBuilder.builder()
+1814 .setProject(project)
+1815 .setScript(stream)
+1816 .setNodeFilters(nodeFilters)
+1817 .setArgString(argString)
+1818 .setNodeThreadcount(nodeThreadcount)
+1819 .setNodeKeepgoing(nodeKeepgoing)
+1820 .setAsUser(asUser)
+1821 .build());
+1822 } finally {
+1823 IOUtils.closeQuietly(stream);
+1824 }
+1825 }
+1826
+1827/**
+1828 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1829 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1830 *
+1831 * @param project name of the project - mandatory
+1832 * @param script inputStream for reading the script to be executed - mandatory
+1833 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1834 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1835 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1836 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1837 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1838 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1839 * @see #runAdhocScript(String, InputStream)
+1840 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1841 * removed in version 10 of this library
+1842 */
+1843publicRundeckExecution triggerAdhocScript(String project, InputStream script) throws RundeckApiException,
+1844 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1845return triggerAdhocScript(project, script, null);
+1846 }
+1847
+1848/**
+1849 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1850 * script will not be dispatched to nodes, but be executed on the RunDeck server.
+1851 *
+1852 * @param project name of the project - mandatory
+1853 * @param script inputStream for reading the script to be executed - mandatory
+1854 * @param options of the script - optional. See {@link OptionsBuilder}.
+1855 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1856 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1857 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1858 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1859 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1860 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1861 * @see #runAdhocScript(String, InputStream, Properties)
+1862 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1863 * removed in version 10 of this library
+1864 */
+1865publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options)
+1866throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1867return triggerAdhocScript(project, script, options, null);
+1868 }
+1869
+1870/**
+1871 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1872 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1873 *
+1874 * @param project name of the project - mandatory
+1875 * @param script inputStream for reading the script to be executed - mandatory
+1876 * @param options of the script - optional. See {@link OptionsBuilder}.
+1877 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1878 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1879 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1880 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1881 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1882 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1883 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+1884 * @see #runAdhocScript(String, InputStream, Properties, Properties)
+1885 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1886 * removed in version 10 of this library
+1887 */
+1888publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
+1889 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+1890 IllegalArgumentException {
+1891return triggerAdhocScript(project, script, options, nodeFilters, null, null);
+1892 }
+1893
+1894/**
+1895 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1896 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1897 *
+1898 * @param project name of the project - mandatory
+1899 * @param script inputStream for reading the script to be executed - mandatory
+1900 * @param options of the script - optional. See {@link OptionsBuilder}.
+1901 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1902 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1903 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1904 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1905 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1906 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1907 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1908 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1909 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1910 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1911 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1912 * removed in version 10 of this library1913 */
-1914publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
-1915 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
-1916 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
-1917 IllegalArgumentException {
-1918if (poolingInterval <= 0) {
-1919 poolingInterval = DEFAULT_POOLING_INTERVAL;
-1920 poolingUnit = DEFAULT_POOLING_UNIT;
-1921 }
-1922if (poolingUnit == null) {
-1923 poolingUnit = DEFAULT_POOLING_UNIT;
-1924 }
-1925
-1926RundeckExecution execution = triggerAdhocScript(project,
-1927 script,
-1928 options,
-1929 nodeFilters,
-1930 nodeThreadcount,
-1931 nodeKeepgoing);
-1932while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
-1933try {
-1934 Thread.sleep(poolingUnit.toMillis(poolingInterval));
-1935 } catch (InterruptedException e) {
-1936break;
-1937 }
-1938 execution = getExecution(execution.getId());
-1939 }
-1940return execution;
-1941 }
-1942
-1943/*
-1944 * Executions
-1945 */
-1946
-1947/**
-1948 * Get all running executions (for all projects)
-1949 *
-1950 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1951 * @throws RundeckApiException in case of error when calling the API
-1952 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1953 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1954 * @see #getRunningExecutions(String)
-1955 */
-1956public List<RundeckExecution> getRunningExecutions() throws RundeckApiException, RundeckApiLoginException,
-1957RundeckApiTokenException {
-1958 List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
-1959for (RundeckProject project : getProjects()) {
-1960 executions.addAll(getRunningExecutions(project.getName()));
-1961 }
-1962return executions;
-1963 }
-1964
-1965/**
-1966 * Get the running executions for the given project
-1967 *
-1968 * @param project name of the project - mandatory
-1969 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1970 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-1971 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1972 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1973 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-1974 * @see #getRunningExecutions()
-1975 */
-1976public List<RundeckExecution> getRunningExecutions(String project) throws RundeckApiException,
-1977 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-1978 AssertUtil.notBlank(project, "project is mandatory get all running executions !");
-1979returnnewApiCall(this).get(newApiPathBuilder("/executions/running").param("project", project),
-1980new ListParser<RundeckExecution>(newExecutionParser(),
-1981"result/executions/execution"));
-1982 }
-1983
-1984/**
-1985 * Get the executions of the given job
-1986 *
-1987 * @param jobId identifier of the job - mandatory
-1988 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-1989 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-1990 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-1991 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-1992 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-1993 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
-1994 */
-1995public List<RundeckExecution> getJobExecutions(String jobId) throws RundeckApiException, RundeckApiLoginException,
-1996 RundeckApiTokenException, IllegalArgumentException {
-1997return getJobExecutions(jobId, (ExecutionStatus) null);
-1998 }
-1999
-2000/**
-2001 * Get the executions of the given job
-2002 *
-2003 * @param jobId identifier of the job - mandatory
-2004 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-2005 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-2006 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2007 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2008 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2009 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
-2010 * invalid
-2011 * @see #getJobExecutions(String, String, Long, Long)
-2012 */
-2013public List<RundeckExecution> getJobExecutions(String jobId, String status) throws RundeckApiException,
-2014 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2015return getJobExecutions(jobId,
-2016 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)));
-2017 }
-2018
-2019/**
-2020 * Get the executions of the given job
-2021 *
-2022 * @param jobId identifier of the job - mandatory
-2023 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-2024 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-2025 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2026 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2027 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2028 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-2029 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
-2030 */
-2031public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status) throws RundeckApiException,
-2032 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2033return getJobExecutions(jobId, status, null, null);
-2034 }
-2035
-2036/**
-2037 * Get the executions of the given job
-2038 *
-2039 * @param jobId identifier of the job - mandatory
-2040 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-2041 * @param max number of results to return - optional (null for all)
-2042 * @param offset the 0-indexed offset for the first result to return - optional
-2043 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-2044 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2045 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2046 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2047 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
-2048 * invalid
-2049 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
-2050 */
-2051public List<RundeckExecution> getJobExecutions(String jobId, String status, Long max, Long offset)
-2052throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2053return getJobExecutions(jobId,
-2054 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)),
-2055 max,
-2056 offset);
-2057 }
-2058
-2059/**
-2060 * Get the executions of the given job
-2061 *
-2062 * @param jobId identifier of the job - mandatory
-2063 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
-2064 * @param max number of results to return - optional (null for all)
-2065 * @param offset the 0-indexed offset for the first result to return - optional
-2066 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-2067 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2068 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2069 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2070 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-2071 */
-2072public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status, Long max, Long offset)
-2073throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2074 AssertUtil.notBlank(jobId, "jobId is mandatory to get the executions of a job !");
-2075returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/executions").param("status", status)
-2076 .param("max", max)
-2077 .param("offset", offset),
-2078new ListParser<RundeckExecution>(newExecutionParser(),
-2079"result/executions/execution"));
-2080 }
-2081
-2082/**
-2083 * Get executions based on query parameters
-2084 *
-2085 * @param query query parameters for the request
-2086 * @param max number of results to return - optional (null for all)
-2087 * @param offset the 0-indexed offset for the first result to return - optional
-2088 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
-2089 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2090 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2091 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2092 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-2093 */
-2094public PagedResults<RundeckExecution> getExecutions(ExecutionQuery query, Long max, Long offset)
-2095throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2096if (!query.notBlank()) {
-2097thrownew IllegalArgumentException("Some execution query parameter must be set");
-2098 }
-2099 AssertUtil.notBlank(query.getProject(), "project is required for execution query");
-2100returnnewApiCall(this).get(newApiPathBuilder("/executions")
-2101 .param(newExecutionQueryParameters(query))
-2102 .param("max", max)
-2103 .param("offset", offset),
-2104new PagedResultParser<RundeckExecution>(
-2105new ListParser<RundeckExecution>(newExecutionParser(), "execution"),
-2106"result/executions"
-2107 )
-2108 );
-2109 }
-2110
-2111/**
-2112 * Get a single execution, identified by the given ID
-2113 *
-2114 * @param executionId identifier of the execution - mandatory
-2115 * @return a {@link RundeckExecution} instance - won't be null
-2116 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
-2117 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2118 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2119 * @throws IllegalArgumentException if the executionId is null
-2120 */
-2121publicRundeckExecution getExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
-2122 RundeckApiTokenException, IllegalArgumentException {
-2123 AssertUtil.notNull(executionId, "executionId is mandatory to get the details of an execution !");
-2124returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString()),
-2125newExecutionParser("result/executions/execution"));
-2126 }
-2127
-2128/**
-2129 * Abort an execution (identified by the given ID). The execution should be running...
-2130 *
-2131 * @param executionId identifier of the execution - mandatory
-2132 * @return a {@link RundeckAbort} instance - won't be null
-2133 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
-2134 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2135 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2136 * @throws IllegalArgumentException if the executionId is null
-2137 */
-2138publicRundeckAbort abortExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
-2139 RundeckApiTokenException, IllegalArgumentException {
-2140 AssertUtil.notNull(executionId, "executionId is mandatory to abort an execution !");
-2141returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/abort"),
-2142newAbortParser("result/abort"));
-2143 }
-2144
-2145/*
-2146 * History
-2147 */
-2148
-2149/**
-2150 * Get the (events) history for the given project
-2151 *
-2152 * @param project name of the project - mandatory
-2153 * @return a {@link RundeckHistory} instance - won't be null
-2154 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2155 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2156 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2157 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2158 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2159 */
-2160publicRundeckHistory getHistory(String project) throws RundeckApiException, RundeckApiLoginException,
-2161 RundeckApiTokenException, IllegalArgumentException {
-2162return getHistory(project, null, null,(String) null, (String) null, null, null, null, null);
-2163 }
-2164
-2165/**
-2166 * Get the (events) history for the given project
-2167 *
-2168 * @param project name of the project - mandatory
-2169 * @param max number of results to return - optional (default to 20)
-2170 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2171 * @return a {@link RundeckHistory} instance - won't be null
-2172 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2173 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2174 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2175 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2176 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2177 */
-2178publicRundeckHistory getHistory(String project, Long max, Long offset) throws RundeckApiException,
-2179 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2180return getHistory(project, null, null, (String)null, (String)null, null, null, max, offset);
-2181 }
-2182
-2183/**
-2184 * Get the (events) history for the given project
-2185 *
-2186 * @param project name of the project - mandatory
-2187 * @param jobId include only events matching the given job ID - optional
-2188 * @param reportId include only events matching the given report ID - optional
-2189 * @param user include only events created by the given user - optional
-2190 * @return a {@link RundeckHistory} instance - won't be null
-2191 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2192 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2193 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2194 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2195 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2196 */
-2197publicRundeckHistory getHistory(String project, String jobId, String reportId, String user)
-2198throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2199return getHistory(project, jobId, reportId, user, null, null, null, null, null);
-2200 }
-2201
-2202/**
-2203 * Get the (events) history for the given project
-2204 *
-2205 * @param project name of the project - mandatory
-2206 * @param jobId include only events matching the given job ID - optional
-2207 * @param reportId include only events matching the given report ID - optional
-2208 * @param user include only events created by the given user - optional
-2209 * @param max number of results to return - optional (default to 20)
-2210 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2211 * @return a {@link RundeckHistory} instance - won't be null
-2212 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2213 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2214 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2215 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2216 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2217 */
-2218publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, Long max, Long offset)
-2219throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2220return getHistory(project, jobId, reportId, user, null, null, null, max, offset);
-2221 }
-2222
-2223/**
-2224 * Get the (events) history for the given project
-2225 *
-2226 * @param project name of the project - mandatory
-2227 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
-2228 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
-2229 * weeks), "5d" (= last 5 days), etc. Optional.
-2230 * @return a {@link RundeckHistory} instance - won't be null
-2231 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2232 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2233 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2234 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2235 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2236 */
-2237publicRundeckHistory getHistory(String project, String recent) throws RundeckApiException,
-2238 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2239return getHistory(project, null, null, null, recent, null, null, null, null);
-2240 }
-2241
-2242/**
-2243 * Get the (events) history for the given project
-2244 *
-2245 * @param project name of the project - mandatory
-2246 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
-2247 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
-2248 * weeks), "5d" (= last 5 days), etc. Optional.
-2249 * @param max number of results to return - optional (default to 20)
-2250 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2251 * @return a {@link RundeckHistory} instance - won't be null
-2252 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2253 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2254 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2255 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2256 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2257 */
-2258publicRundeckHistory getHistory(String project, String recent, Long max, Long offset) throws RundeckApiException,
-2259 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2260return getHistory(project, null, null, null, recent, null, null, max, offset);
-2261 }
-2262
-2263/**
-2264 * Get the (events) history for the given project
-2265 *
-2266 * @param project name of the project - mandatory
-2267 * @param begin date for the earlier events to retrieve - optional
-2268 * @param end date for the latest events to retrieve - optional
-2269 * @return a {@link RundeckHistory} instance - won't be null
-2270 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2271 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2272 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2273 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2274 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2275 */
-2276publicRundeckHistory getHistory(String project, Date begin, Date end) throws RundeckApiException,
-2277 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2278return getHistory(project, null, null, (String)null, (String)null, begin, end, null, null);
-2279 }
-2280
-2281/**
-2282 * Get the (events) history for the given project
-2283 *
-2284 * @param project name of the project - mandatory
-2285 * @param begin date for the earlier events to retrieve - optional
-2286 * @param end date for the latest events to retrieve - optional
-2287 * @param max number of results to return - optional (default to 20)
-2288 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2289 * @return a {@link RundeckHistory} instance - won't be null
-2290 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2291 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2292 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2293 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2294 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
-2295 */
-2296publicRundeckHistory getHistory(String project, Date begin, Date end, Long max, Long offset)
-2297throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2298return getHistory(project, null, null, (String)null, (String) null, begin, end, max, offset);
-2299 }
-2300
-2301/**
-2302 * Get the (events) history for the given project
-2303 *
-2304 * @param project name of the project - mandatory
-2305 * @param jobId include only events matching the given job ID - optional
-2306 * @param reportId include only events matching the given report ID - optional
-2307 * @param user include only events created by the given user - optional
-2308 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
-2309 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
-2310 * weeks), "5d" (= last 5 days), etc. Optional.
-2311 * @param begin date for the earlier events to retrieve - optional
-2312 * @param end date for the latest events to retrieve - optional
-2313 * @param max number of results to return - optional (default to 20)
-2314 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2315 * @return a {@link RundeckHistory} instance - won't be null
-2316 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2317 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2318 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2319 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2320 */
-2321publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, String recent,
-2322 Date begin, Date end, Long max, Long offset) throws RundeckApiException, RundeckApiLoginException,
-2323 RundeckApiTokenException, IllegalArgumentException {
-2324 AssertUtil.notBlank(project, "project is mandatory to get the history !");
-2325returnnewApiCall(this).get(newApiPathBuilder("/history").param("project", project)
-2326 .param("jobIdFilter", jobId)
-2327 .param("reportIdFilter", reportId)
-2328 .param("userFilter", user)
-2329 .param("recentFilter", recent)
-2330 .param("begin", begin)
-2331 .param("end", end)
-2332 .param("max", max)
-2333 .param("offset", offset),
-2334newHistoryParser("result/events"));
-2335 }
-2336
-2337/**
-2338 * Get the (events) history for the given project
-2339 *
-2340 * @param project name of the project - mandatory
-2341 * @param includeJobNames list of job names ("group/name") to include results for
-2342 * @param excludeJobNames list of job names ("group/name") to exclude results for
-2343 * @param user include only events created by the given user - optional
-2344 * @param recent include only events matching the given period of time. Format : "XY", where X is an
-2345 * integer, and Y is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year).
-2346 * Example : "2w" (= last 2 weeks), "5d" (= last 5 days), etc. Optional.
-2347 * @param begin date for the earlier events to retrieve - optional
-2348 * @param end date for the latest events to retrieve - optional
-2349 * @param max number of results to return - optional (default to 20)
-2350 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
-2351 *
-2352 * @return a {@link RundeckHistory} instance - won't be null
-2353 *
-2354 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2355 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2356 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2357 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+1914publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
+1915 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+1916 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1917return triggerAdhocScript(project, script, options, nodeFilters, nodeThreadcount, nodeKeepgoing, null);
+1918 }
+1919/**
+1920 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1921 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1922 *
+1923 * @param project name of the project - mandatory
+1924 * @param script inputStream for reading the script to be executed - mandatory
+1925 * @param options of the script - optional. See {@link OptionsBuilder}.
+1926 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1927 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1928 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1929 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1930 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1931 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1932 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1933 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1934 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1935 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1936 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1937 * removed in version 10 of this library
+1938 */
+1939publicRundeckExecution triggerAdhocScript(String project, InputStream script, Properties options,
+1940 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, String asUser) throws RundeckApiException,
+1941 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1942return triggerAdhocScript(project, script, ParametersUtil.generateArgString(options), nodeFilters,
+1943 nodeThreadcount, nodeKeepgoing, asUser);
+1944 }
+1945/**
+1946 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+1947 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1948 *
+1949 * @param project name of the project - mandatory
+1950 * @param script inputStream for reading the script to be executed - mandatory
+1951 * @param argString arguments of the script - optional.
+1952 * @param nodeFilters for selecting nodes on which the command will be executed. See {@link NodeFiltersBuilder}
+1953 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+1954 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+1955 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1956 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1957 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1958 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1959 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1960 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+1961 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+1962 * @deprecated use {@link #triggerAdhocScript(RunAdhocScript)}, this method will be
+1963 * removed in version 10 of this library
+1964 */
+1965publicRundeckExecution triggerAdhocScript(String project, InputStream script, String argString,
+1966 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, String asUser) throws RundeckApiException,
+1967 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+1968return triggerAdhocScript(RunAdhocScriptBuilder.builder()
+1969 .setProject(project)
+1970 .setScript(script)
+1971 .setNodeFilters(nodeFilters)
+1972 .setArgString(argString)
+1973 .setNodeThreadcount(nodeThreadcount)
+1974 .setNodeKeepgoing(nodeKeepgoing)
+1975 .setAsUser(asUser)
+1976 .build());
+1977 }
+1978
+1979/**
+1980 * Trigger the execution of an ad-hoc script read from a file, and return immediately (without waiting the end of
+1981 * the execution). The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+1982 *
+1983 * @param script the RunAdhocScript, see {@link RunAdhocScriptBuilder}
+1984 * @param scriptFilename a file to read as the input script stream
+1985 *
+1986 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+1987 *
+1988 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+1989 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+1990 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+1991 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+1992 * @throws IOException if an error occurs reading the script file
+1993 * @see #triggerAdhocScript(RunAdhocScript)
+1994 * @see #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)
+1995 */
+1996publicRundeckExecution triggerAdhocScript(finalRunAdhocScript script, final String scriptFilename) throws
+1997 RundeckApiException,
+1998 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+1999 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to trigger an ad-hoc script !");
+2000 FileInputStream stream = null;
+2001try {
+2002 stream = FileUtils.openInputStream(new File(scriptFilename));
+2003return triggerAdhocScript(RunAdhocScriptBuilder.builder(script)
+2004 .setScript(stream)
+2005 .build());
+2006 } finally {
+2007 IOUtils.closeQuietly(stream);
+2008 }
+2009 }
+2010/**
+2011 * Trigger the execution of an ad-hoc script, and return immediately (without waiting the end of the execution). The
+2012 * script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2013 *
+2014 * @param script the RunAdhocScript, see {@link RunAdhocScriptBuilder}
+2015 * @return a {@link RundeckExecution} instance for the newly created (and running) execution - won't be null
+2016 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2017 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2018 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2019 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2020 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+2021 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2022 */
+2023publicRundeckExecution triggerAdhocScript(RunAdhocScript script) throws RundeckApiException,
+2024 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2025 AssertUtil.notBlank(script.getProject(), "project is mandatory to trigger an ad-hoc script !");
+2026 AssertUtil.notNull(script.getScript(), "script is mandatory to trigger an ad-hoc script !");
+2027ApiPathBuilder apiPath = newApiPathBuilder("/run/script").param("project", script.getProject())
+2028 .attach("scriptFile",
+2029 script.getScript())
+2030 .param("argString",script.getArgString())
+2031 .param("nodeThreadcount",
+2032 script.getNodeThreadcount())
+2033 .param("nodeKeepgoing",
+2034 script.getNodeKeepgoing())
+2035 .param("scriptInterpreter",
+2036 script.getScriptInterpreter())
+2037 .param("interpreterArgsQuoted",
+2038 script.getInterpreterArgsQuoted())
+2039 .nodeFilters(script.getNodeFilters());
+2040if(null!=script.getAsUser()) {
+2041 apiPath.param("asUser", script.getAsUser());
+2042 }
+2043RundeckExecution execution = newApiCall(this).post(apiPath, newExecutionParser("result/execution"));
+2044// the first call just returns the ID of the execution, so we need another call to get a "real" execution
+2045return getExecution(execution.getId());
+2046 }
+2047
+2048/**
+2049 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2050 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2051 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+2052 *
+2053 * @param project name of the project - mandatory
+2054 * @param scriptFilename filename of the script to be executed - mandatory
+2055 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2056 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2057 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2058 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2059 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2060 * @throws IOException if we failed to read the file
+2061 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2062 * @see #triggerAdhocScript(String, String)
+2063 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2064 * removed in version 10 of this library
+2065 */
+2066publicRundeckExecution runAdhocScript(String project, String scriptFilename) throws RundeckApiException,
+2067 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2068return runAdhocScript(project, scriptFilename, null);
+2069 }
+2070
+2071/**
+2072 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2073 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2074 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+2075 * RunDeck server.
+2076 *
+2077 * @param project name of the project - mandatory
+2078 * @param scriptFilename filename of the script to be executed - mandatory
+2079 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2080 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2081 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2082 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2083 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2084 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2085 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2086 * @throws IOException if we failed to read the file
+2087 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2088 * @see #triggerAdhocScript(String, String)
+2089 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2090 * removed in version 10 of this library
+2091 */
+2092publicRundeckExecution runAdhocScript(String project, String scriptFilename, long poolingInterval,
+2093 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2094 IllegalArgumentException, IOException {
+2095return runAdhocScript(project, scriptFilename, null, poolingInterval, poolingUnit);
+2096 }
+2097
+2098/**
+2099 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2100 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2101 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+2102 *
+2103 * @param project name of the project - mandatory
+2104 * @param scriptFilename filename of the script to be executed - mandatory
+2105 * @param options of the script - optional. See {@link OptionsBuilder}.
+2106 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2107 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2108 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2109 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2110 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2111 * @throws IOException if we failed to read the file
+2112 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2113 * @see #triggerAdhocScript(String, String, Properties)
+2114 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2115 * removed in version 10 of this library
+2116 */
+2117publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options)
+2118throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
+2119 IOException {
+2120return runAdhocScript(project, scriptFilename, options, null);
+2121 }
+2122
+2123/**
+2124 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2125 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2126 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+2127 * RunDeck server.
+2128 *
+2129 * @param project name of the project - mandatory
+2130 * @param scriptFilename filename of the script to be executed - mandatory
+2131 * @param options of the script - optional. See {@link OptionsBuilder}.
+2132 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2133 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2134 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2135 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2136 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2137 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2138 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2139 * @throws IOException if we failed to read the file
+2140 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2141 * @see #triggerAdhocScript(String, String, Properties)
+2142 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2143 * removed in version 10 of this library
+2144 */
+2145publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+2146long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+2147 RundeckApiTokenException, IllegalArgumentException, IOException {
+2148return runAdhocScript(project, scriptFilename, options, null, poolingInterval, poolingUnit);
+2149 }
+2150
+2151/**
+2152 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2153 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2154 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2155 *
+2156 * @param project name of the project - mandatory
+2157 * @param scriptFilename filename of the script to be executed - mandatory
+2158 * @param options of the script - optional. See {@link OptionsBuilder}.
+2159 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2160 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2161 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2162 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2163 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2164 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2165 * @throws IOException if we failed to read the file
+2166 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2167 * @see #triggerAdhocScript(String, String, Properties, Properties)
+2168 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2169 * removed in version 10 of this library
+2170 */
+2171publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+2172 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2173 IllegalArgumentException, IOException {
+2174return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null);
+2175 }
+2176
+2177/**
+2178 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2179 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2180 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2181 * parameter.
+2182 *
+2183 * @param project name of the project - mandatory
+2184 * @param scriptFilename filename of the script to be executed - mandatory
+2185 * @param options of the script - optional. See {@link OptionsBuilder}.
+2186 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2187 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2188 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2189 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2190 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2191 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2192 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2193 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2194 * @throws IOException if we failed to read the file
+2195 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2196 * @see #triggerAdhocScript(String, String, Properties, Properties)
+2197 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2198 * removed in version 10 of this library
+2199 */
+2200publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+2201 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
+2202 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2203return runAdhocScript(project, scriptFilename, options, nodeFilters, null, null, poolingInterval, poolingUnit);
+2204 }
+2205
+2206/**
+2207 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2208 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2209 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2210 *
+2211 * @param project name of the project - mandatory
+2212 * @param scriptFilename filename of the script to be executed - mandatory
+2213 * @param options of the script - optional. See {@link OptionsBuilder}.
+2214 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2215 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+2216 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+2217 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2218 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2219 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2220 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2221 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2222 * @throws IOException if we failed to read the file
+2223 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2224 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+2225 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2226 * removed in version 10 of this library
+2227 */
+2228publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+2229 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+2230 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2231return runAdhocScript(project,
+2232 scriptFilename,
+2233 options,
+2234 nodeFilters,
+2235 nodeThreadcount,
+2236 nodeKeepgoing,
+2237 DEFAULT_POOLING_INTERVAL,
+2238 DEFAULT_POOLING_UNIT);
+2239 }
+2240
+2241/**
+2242 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2243 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2244 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2245 * parameter.
+2246 *
+2247 * @param project name of the project - mandatory
+2248 * @param scriptFilename filename of the script to be executed - mandatory
+2249 * @param options of the script - optional. See {@link OptionsBuilder}.
+2250 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2251 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+2252 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+2253 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2254 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2255 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2256 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2257 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2258 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2259 * @throws IllegalArgumentException if the project or scriptFilename is blank (null, empty or whitespace)
+2260 * @throws IOException if we failed to read the file
+2261 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2262 * @see #triggerAdhocScript(String, String, Properties, Properties, Integer, Boolean)
+2263 *
+2264 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2265 * removed in version 10 of this library
+2266 */
+2267publicRundeckExecution runAdhocScript(String project, String scriptFilename, Properties options,
+2268 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
+2269 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2270 IllegalArgumentException, IOException {
+2271 AssertUtil.notBlank(scriptFilename, "scriptFilename is mandatory to run an ad-hoc script !");
+2272 FileInputStream stream = null;
+2273try {
+2274 stream = FileUtils.openInputStream(new File(scriptFilename));
+2275return runAdhocScript(RunAdhocScriptBuilder.builder()
+2276 .setProject(project)
+2277 .setScript(stream)
+2278 .setNodeFilters(nodeFilters)
+2279 .setArgString(ParametersUtil.generateArgString(options))
+2280 .setNodeThreadcount(nodeThreadcount)
+2281 .setNodeKeepgoing(nodeKeepgoing)
+2282 .build(),
+2283 poolingInterval,
+2284 poolingUnit);
+2285 } finally {
+2286 IOUtils.closeQuietly(stream);
+2287 }
+2288 }
+2289
+2290/**
+2291 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2292 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2293 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+2294 *
+2295 * @param project name of the project - mandatory
+2296 * @param script inputStream for reading the script to be executed - mandatory
+2297 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2298 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2299 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2300 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2301 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2302 * @throws IOException if we failed to read the file
+2303 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2304 * @see #triggerAdhocScript(String, InputStream)
+2305 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2306 * removed in version 10 of this library
+2307 */
+2308publicRundeckExecution runAdhocScript(String project, InputStream script) throws RundeckApiException,
+2309 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2310return runAdhocScript(project, script, null);
+2311 }
+2312
+2313/**
+2314 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2315 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2316 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+2317 * RunDeck server.
+2318 *
+2319 * @param project name of the project - mandatory
+2320 * @param script inputStream for reading the script to be executed - mandatory
+2321 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2322 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2323 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2324 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2325 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2326 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2327 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2328 * @throws IOException if we failed to read the file
+2329 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2330 * @see #triggerAdhocScript(String, InputStream)
+2331 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2332 * removed in version 10 of this library
+2333 */
+2334publicRundeckExecution runAdhocScript(String project, InputStream script, long poolingInterval,
+2335 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2336 IllegalArgumentException, IOException {
+2337return runAdhocScript(project, script, null, poolingInterval, poolingUnit);
+2338 }
+2339
+2340/**
+2341 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2342 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2343 * running. The script will not be dispatched to nodes, but be executed on the RunDeck server.
+2344 *
+2345 * @param project name of the project - mandatory
+2346 * @param script inputStream for reading the script to be executed - mandatory
+2347 * @param options of the script - optional. See {@link OptionsBuilder}.
+2348 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2349 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2350 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2351 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2352 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2353 * @throws IOException if we failed to read the file
+2354 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2355 * @see #triggerAdhocScript(String, InputStream, Properties)
+2356 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2357 * removed in version 10 of this library2358 */
-2359publicRundeckHistory getHistory(String project,
-2360 String user,
-2361 String recent,
-2362 List<String> includeJobNames,
-2363 List<String> excludeJobNames,
-2364 Date begin,
-2365 Date end,
-2366 Long max,
-2367 Long offset)
-2368throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2369
-2370 AssertUtil.notBlank(project, "project is mandatory to get the history !");
-2371finalApiPathBuilder builder = newApiPathBuilder("/history").param("project", project)
-2372 .field("jobListFilter", includeJobNames)
-2373 .field("excludeJobListFilter", excludeJobNames)
-2374 .param("userFilter", user)
-2375 .param("recentFilter", recent)
-2376 .param("begin", begin)
-2377 .param("end", end)
-2378 .param("max", max)
-2379 .param("offset", offset);
-2380
-2381returnnewApiCall(this).postOrGet(builder, newHistoryParser("result/events"));
-2382 }
-2383
-2384/*
-2385 * Nodes
-2386 */
-2387
-2388/**
-2389 * List all nodes (for all projects)
-2390 *
-2391 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-2392 * @throws RundeckApiException in case of error when calling the API
-2393 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2394 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2395 */
-2396public List<RundeckNode> getNodes() throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException {
-2397 List<RundeckNode> nodes = new ArrayList<RundeckNode>();
-2398for (RundeckProject project : getProjects()) {
-2399 nodes.addAll(getNodes(project.getName()));
-2400 }
-2401return nodes;
-2402 }
-2403
-2404/**
-2405 * List all nodes that belongs to the given project
-2406 *
-2407 * @param project name of the project - mandatory
-2408 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-2409 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2410 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2411 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2412 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2413 * @see #getNodes(String, Properties)
-2414 */
-2415public List<RundeckNode> getNodes(String project) throws RundeckApiException, RundeckApiLoginException,
-2416 RundeckApiTokenException, IllegalArgumentException {
-2417return getNodes(project, null);
-2418 }
-2419
-2420/**
-2421 * List nodes that belongs to the given project
-2422 *
-2423 * @param project name of the project - mandatory
-2424 * @param nodeFilters for filtering the nodes - optional. See {@link NodeFiltersBuilder}
-2425 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
-2426 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
-2427 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2428 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2429 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
-2430 */
-2431public List<RundeckNode> getNodes(String project, Properties nodeFilters) throws RundeckApiException,
-2432 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2433 AssertUtil.notBlank(project, "project is mandatory to get all nodes !");
-2434returnnewApiCall(this).get(newApiPathBuilder("/resources").param("project", project)
-2435 .nodeFilters(nodeFilters),
-2436new ListParser<RundeckNode>(newNodeParser(), "project/node"));
-2437 }
-2438
-2439/**
-2440 * Get the definition of a single node
-2441 *
-2442 * @param name of the node - mandatory
-2443 * @param project name of the project - mandatory
-2444 * @return a {@link RundeckNode} instance - won't be null
-2445 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
-2446 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2447 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2448 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
-2449 */
-2450publicRundeckNode getNode(String name, String project) throws RundeckApiException, RundeckApiLoginException,
-2451 RundeckApiTokenException, IllegalArgumentException {
-2452 AssertUtil.notBlank(name, "the name of the node is mandatory to get a node !");
-2453 AssertUtil.notBlank(project, "project is mandatory to get a node !");
-2454returnnewApiCall(this).get(newApiPathBuilder("/resource/", name).param("project", project),
-2455newNodeParser("project/node"));
-2456 }
-2457
-2458/**
-2459 * Get the output of a job execution
-2460 *
-2461 * @param id of the execution - mandatory
-2462 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-2463 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
-2464 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2465 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2466 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
-2467 */
-2468public InputStream getOutput(String executionId) throws RundeckApiException, RundeckApiLoginException,
-2469 RundeckApiTokenException, IllegalArgumentException {
-2470 AssertUtil.notBlank(executionId, "the execution id is mandatory to get execution output !");
-2471returnnewApiCall(this).getNonApi(newApiPathBuilder("/execution/downloadOutput/", executionId));
-2472 }
-2473
-2474/**
-2475 * Get the html page of the user's profile
-2476 *
-2477 * @param username - mandatory
-2478 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-2479 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
-2480 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2481 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2482 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
-2483 */
-2484public InputStream getProfilePage(String username) throws RundeckApiException, RundeckApiLoginException,
-2485 RundeckApiTokenException, IllegalArgumentException {
-2486 AssertUtil.notBlank(username, "the username is mandatory to get profile page !");
-2487returnnewApiCall(this).getNonApi(newApiPathBuilder("/user/profile?login=", username));
-2488 }
-2489
-2490
-2491/**
-2492 * Generate a new token and get the result page (which is the html page of the user's profile)
-2493 *
-2494 * @param username - mandatory
-2495 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
-2496 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
-2497 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2498 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2499 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
-2500 */
-2501public InputStream generateToken(String username) throws RundeckApiException, RundeckApiLoginException,
-2502 RundeckApiTokenException, IllegalArgumentException {
-2503 AssertUtil.notBlank(username, "the username is mandatory to generate the token");
-2504returnnewApiCall(this).getNonApi(newApiPathBuilder("/user/generateApiToken?login=", username));
-2505 }
-2506
-2507
-2508/**
-2509 * Get the execution output of the given job
-2510 *
-2511 * @param executionId identifier of the execution - mandatory
-2512 * @param offset byte offset to read from in the file. 0 indicates the beginning.
-2513 * @param lastlines nnumber of lines to retrieve from the end of the available output. If specified it will override the offset value and return only the specified number of lines at the end of the log.
-2514 * @param lastmod epoch datestamp in milliseconds, return results only if modification changed since the specified date OR if more data is available at the given offset
-2515 * @param maxlines maximum number of lines to retrieve forward from the specified offset.
-2516 * @return {@link RundeckOutput}
-2517 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2518 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2519 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2520 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-2521 */
-2522publicRundeckOutput getJobExecutionOutput(Long executionId, int offset, int lastlines, long lastmod, int maxlines)
-2523throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2524 AssertUtil.notNull(executionId, "executionId is mandatory to get the output of a job execution!");
-2525returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/output.xml").param("offset", offset)
-2526 .param("lastlines", lastlines)
-2527 .param("lastmod", lastmod)
-2528 .param("maxlines", maxlines),
-2529newOutputParser("result/output", createOutputEntryParser()));
-2530 }
-2531
-2532
-2533/**
-2534 * Get the execution output of the given job
-2535 *
-2536 * @param jobId identifier of the job - mandatory
-2537 * @param offset byte offset to read from in the file. 0 indicates the beginning.
-2538 * @param lastmod epoch datestamp in milliseconds, return results only if modification changed since the specified date OR if more data is available at the given offset
-2539 * @param maxlines maximum number of lines to retrieve forward from the specified offset.
-2540 * @return {@link RundeckOutput}
-2541 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
-2542 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2543 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2544 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
-2545 */
-2546publicRundeckOutput getJobExecutionOutput(Long executionId, int offset, long lastmod, int maxlines)
-2547throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
-2548 AssertUtil.notNull(executionId, "executionId is mandatory to get the output of a job execution!");
-2549returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/output.xml").param("offset", offset)
-2550 .param("lastmod", lastmod)
-2551 .param("maxlines", maxlines),
-2552newOutputParser("result/output", createOutputEntryParser()));
-2553 }
-2554
-2555privateOutputEntryParser createOutputEntryParser() {
-2556if (getApiVersion() <= Version.V5.versionNumber) {
-2557returnnewOutputEntryParserV5();
-2558 }else{
-2559returnnewOutputEntryParser();
-2560 }
-2561 }
-2562
-2563
-2564/*
-2565 * System Info
-2566 */
-2567
-2568/**
-2569 * Get system informations about the RunDeck server
-2570 *
-2571 * @return a {@link RundeckSystemInfo} instance - won't be null
-2572 * @throws RundeckApiException in case of error when calling the API
-2573 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
-2574 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
-2575 */
-2576publicRundeckSystemInfo getSystemInfo() throws RundeckApiException, RundeckApiLoginException,
-2577RundeckApiTokenException {
-2578returnnewApiCall(this).get(newApiPathBuilder("/system/info"), newSystemInfoParser("result/system"));
-2579 }
-2580
-2581/**
-2582 * @return the URL of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
-2583 */
-2584public String getUrl() {
-2585return url;
-2586 }
-2587
-2588/**
-2589 * @return the auth-token used for authentication on the RunDeck instance (null if using login-based or session-based auth)
-2590 */
-2591public String getToken() {
-2592return token;
-2593 }
-2594
-2595/**
-2596 * @return the login used for authentication on the RunDeck instance (null if using token-based or session-based auth)
-2597 */
-2598public String getLogin() {
-2599return login;
-2600 }
-2601
-2602/**
-2603 * @return the password used for authentication on the RunDeck instance (null if using token-based or session-based auth)
-2604 */
-2605public String getPassword() {
-2606return password;
-2607 }
-2608
-2609/**
-2610 * @return the sessionID used for authentication on the RunDeck instance (null if using login-based or token-based auth)
-2611 */
-2612public String getSessionID() {
-2613return sessionID;
-2614 }
-2615
-2616 @Override
-2617public String toString() {
-2618 StringBuilder str = new StringBuilder();
-2619 str.append("RundeckClient ").append(API_VERSION);
-2620 str.append(" [").append(url).append("] ");
-2621if (token != null) {
-2622 str.append("(token=").append(token).append(")");
-2623 } else {
-2624 str.append("(credentials=").append(login).append("|").append(password).append(")");
-2625 }
-2626return str.toString();
-2627 }
-2628
-2629 @Override
-2630publicint hashCode() {
-2631finalint prime = 31;
-2632int result = 1;
-2633 result = prime * result + ((login == null) ? 0 : login.hashCode());
-2634 result = prime * result + ((password == null) ? 0 : password.hashCode());
-2635 result = prime * result + ((token == null) ? 0 : token.hashCode());
-2636 result = prime * result + ((url == null) ? 0 : url.hashCode());
-2637return result;
-2638 }
-2639
-2640 @Override
-2641publicboolean equals(Object obj) {
-2642if (this == obj)
-2643returntrue;
-2644if (obj == null)
-2645return false;
-2646if (getClass() != obj.getClass())
-2647return false;
-2648RundeckClient other = (RundeckClient) obj;
-2649if (login == null) {
-2650if (other.login != null)
-2651return false;
-2652 } elseif (!login.equals(other.login))
-2653return false;
-2654if (password == null) {
-2655if (other.password != null)
-2656return false;
-2657 } elseif (!password.equals(other.password))
-2658return false;
-2659if (token == null) {
-2660if (other.token != null)
-2661return false;
-2662 } elseif (!token.equals(other.token))
-2663return false;
-2664if (url == null) {
-2665if (other.url != null)
-2666return false;
-2667 } elseif (!url.equals(other.url))
-2668return false;
-2669returntrue;
-2670 }
-2671
-2672 }
+2359publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options)
+2360throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException,
+2361 IOException {
+2362return runAdhocScript(project, script, options, null);
+2363 }
+2364
+2365/**
+2366 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2367 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2368 * finished (or aborted) or is still running. The script will not be dispatched to nodes, but be executed on the
+2369 * RunDeck server.
+2370 *
+2371 * @param project name of the project - mandatory
+2372 * @param script inputStream for reading the script to be executed - mandatory
+2373 * @param options of the script - optional. See {@link OptionsBuilder}.
+2374 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2375 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2376 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2377 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2378 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2379 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2380 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2381 * @throws IOException if we failed to read the file
+2382 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2383 * @see #triggerAdhocScript(String, InputStream, Properties)
+2384 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2385 * removed in version 10 of this library
+2386 */
+2387publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2388long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException,
+2389 RundeckApiTokenException, IllegalArgumentException, IOException {
+2390return runAdhocScript(project, script, options, null, poolingInterval, poolingUnit);
+2391 }
+2392
+2393/**
+2394 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2395 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2396 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2397 *
+2398 * @param project name of the project - mandatory
+2399 * @param script inputStream for reading the script to be executed - mandatory
+2400 * @param options of the script - optional. See {@link OptionsBuilder}.
+2401 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2402 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2403 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2404 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2405 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2406 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2407 * @throws IOException if we failed to read the file
+2408 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2409 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
+2410 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2411 * removed in version 10 of this library
+2412 */
+2413publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2414 Properties nodeFilters) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2415 IllegalArgumentException, IOException {
+2416return runAdhocScript(project, script, options, nodeFilters, null, null);
+2417 }
+2418
+2419/**
+2420 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2421 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2422 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2423 * parameter.
+2424 *
+2425 * @param project name of the project - mandatory
+2426 * @param script inputStream for reading the script to be executed - mandatory
+2427 * @param options of the script - optional. See {@link OptionsBuilder}.
+2428 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2429 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2430 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2431 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2432 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2433 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2434 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2435 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2436 * @throws IOException if we failed to read the file
+2437 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2438 * @see #triggerAdhocScript(String, InputStream, Properties, Properties)
+2439 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2440 * removed in version 10 of this library
+2441 */
+2442publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2443 Properties nodeFilters, long poolingInterval, TimeUnit poolingUnit) throws RundeckApiException,
+2444 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2445return runAdhocScript(project, script, options, nodeFilters, null, null, poolingInterval, poolingUnit);
+2446 }
+2447
+2448/**
+2449 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2450 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2451 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2452 *
+2453 * @param project name of the project - mandatory
+2454 * @param script inputStream for reading the script to be executed - mandatory
+2455 * @param options of the script - optional. See {@link OptionsBuilder}.
+2456 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2457 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+2458 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+2459 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2460 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2461 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2462 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2463 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2464 * @throws IOException if we failed to read the file
+2465 * @see #runAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2466 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+2467 * @deprecated use {@link #runAdhocScript(RunAdhocScript)}, this method will be
+2468 * removed in version 10 of this library
+2469 */
+2470publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2471 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing) throws RundeckApiException,
+2472 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2473return runAdhocScript(project,
+2474 script,
+2475 options,
+2476 nodeFilters,
+2477 nodeThreadcount,
+2478 nodeKeepgoing,
+2479 DEFAULT_POOLING_INTERVAL,
+2480 DEFAULT_POOLING_UNIT);
+2481 }
+2482
+2483/**
+2484 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2485 * server at regular interval (every 5 seconds) to know if the execution is finished (or aborted) or is still
+2486 * running. The script will be dispatched to nodes, accordingly to the nodeFilters parameter.
+2487 *
+2488 * @param script the RunAdhocScript, see {@link RunAdhocScriptBuilder}
+2489 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2490 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2491 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2492 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2493 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2494 * @throws IOException if we failed to read the file
+2495 * @see #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)
+2496 * @see #triggerAdhocScript(RunAdhocScript)
+2497 */
+2498publicRundeckExecution runAdhocScript(RunAdhocScript script) throws RundeckApiException,
+2499 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException, IOException {
+2500return runAdhocScript(script,
+2501 DEFAULT_POOLING_INTERVAL,
+2502 DEFAULT_POOLING_UNIT);
+2503 }
+2504
+2505/**
+2506 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2507 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2508 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2509 * parameter.
+2510 *
+2511 * @param project name of the project - mandatory
+2512 * @param script inputStream for reading the script to be executed - mandatory
+2513 * @param options of the script - optional. See {@link OptionsBuilder}.
+2514 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2515 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+2516 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+2517 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2518 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2519 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2520 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2521 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2522 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2523 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2524 * @throws IOException if we failed to read the file
+2525 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2526 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+2527 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2528 * removed in version 10 of this library
+2529 */
+2530publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2531 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, long poolingInterval,
+2532 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2533 IllegalArgumentException {
+2534return runAdhocScript(project, script, options, nodeFilters, nodeThreadcount, nodeKeepgoing, null, poolingInterval, poolingUnit);
+2535 }
+2536
+2537/**
+2538 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2539 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2540 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2541 * parameter.
+2542 *
+2543 * @param project name of the project - mandatory
+2544 * @param script inputStream for reading the script to be executed - mandatory
+2545 * @param options of the script - optional. See {@link OptionsBuilder}.
+2546 * @param nodeFilters for selecting nodes on which the script will be executed. See {@link NodeFiltersBuilder}
+2547 * @param nodeThreadcount thread count to use (for parallelizing when running on multiple nodes) - optional
+2548 * @param nodeKeepgoing if true, continue executing on other nodes even if some fail - optional
+2549 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2550 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2551 *
+2552 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2553 *
+2554 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2555 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2556 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2557 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2558 * @throws IOException if we failed to read the file
+2559 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2560 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+2561 * @deprecated use {@link #runAdhocScript(RunAdhocScript, long, java.util.concurrent.TimeUnit)}, this method will be
+2562 * removed in version 10 of this library
+2563 */
+2564publicRundeckExecution runAdhocScript(String project, InputStream script, Properties options,
+2565 Properties nodeFilters, Integer nodeThreadcount, Boolean nodeKeepgoing, String asUser, long poolingInterval,
+2566 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2567 IllegalArgumentException {
+2568return runAdhocScript(RunAdhocScriptBuilder.builder()
+2569 .setProject(project)
+2570 .setScript(script)
+2571 .setNodeFilters(nodeFilters)
+2572 .setArgString(ParametersUtil.generateArgString(options))
+2573 .setNodeThreadcount(nodeThreadcount)
+2574 .setNodeKeepgoing(nodeKeepgoing)
+2575 .setAsUser(asUser)
+2576 .build(), poolingInterval, poolingUnit);
+2577 }
+2578
+2579/**
+2580 * Run an ad-hoc script read from a file, and wait until its execution is finished (or aborted) to return. We will
+2581 * poll the RunDeck server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the
+2582 * execution is finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to
+2583 * the nodeFilters parameter.
+2584 *
+2585 * @param script the RunAdhocScript, see {@link RunAdhocScriptBuilder}
+2586 * @param scriptFilename filename of a script to read
+2587 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2588 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2589 *
+2590 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2591 *
+2592 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2593 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2594 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2595 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2596 * @throws IOException if we failed to read the file
+2597 * @see #runAdhocScript(RunAdhocScript)
+2598 * @see #triggerAdhocScript(RunAdhocScript, String)
+2599 */
+2600publicRundeckExecution runAdhocScript(finalRunAdhocScript script, final String scriptFilename,
+2601finallong poolingInterval, final TimeUnit poolingUnit) throws RundeckApiException,
+2602 RundeckApiLoginException, RundeckApiTokenException,
+2603 IllegalArgumentException, IOException {
+2604 FileInputStream stream = null;
+2605try {
+2606 stream = FileUtils.openInputStream(new File(scriptFilename));
+2607return runAdhocScript(RunAdhocScriptBuilder.builder(script)
+2608 .setScript(stream)
+2609 .build(), poolingInterval, poolingUnit);
+2610 } finally {
+2611 IOUtils.closeQuietly(stream);
+2612 }
+2613 }
+2614/**
+2615 * Run an ad-hoc script, and wait until its execution is finished (or aborted) to return. We will poll the RunDeck
+2616 * server at regular interval (configured by the poolingInterval/poolingUnit couple) to know if the execution is
+2617 * finished (or aborted) or is still running. The script will be dispatched to nodes, accordingly to the nodeFilters
+2618 * parameter.
+2619 *
+2620 * @param script the RunAdhocScript, see {@link RunAdhocScriptBuilder}
+2621 * @param poolingInterval for checking the status of the execution. Must be > 0.
+2622 * @param poolingUnit unit (seconds, milli-seconds, ...) of the interval. Default to seconds.
+2623 * @return a {@link RundeckExecution} instance for the (finished/aborted) execution - won't be null
+2624 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2625 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2626 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2627 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace) or the script is null
+2628 * @throws IOException if we failed to read the file
+2629 * @see #runAdhocScript(String, String, Properties, Properties, Integer, Boolean, long, TimeUnit)
+2630 * @see #triggerAdhocScript(String, InputStream, Properties, Properties, Integer, Boolean)
+2631 */
+2632publicRundeckExecution runAdhocScript(finalRunAdhocScript script, long poolingInterval,
+2633 TimeUnit poolingUnit) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException,
+2634 IllegalArgumentException {
+2635if (poolingInterval <= 0) {
+2636 poolingInterval = DEFAULT_POOLING_INTERVAL;
+2637 poolingUnit = DEFAULT_POOLING_UNIT;
+2638 }
+2639if (poolingUnit == null) {
+2640 poolingUnit = DEFAULT_POOLING_UNIT;
+2641 }
+2642
+2643RundeckExecution execution = triggerAdhocScript(script);
+2644while (ExecutionStatus.RUNNING.equals(execution.getStatus())) {
+2645try {
+2646 Thread.sleep(poolingUnit.toMillis(poolingInterval));
+2647 } catch (InterruptedException e) {
+2648break;
+2649 }
+2650 execution = getExecution(execution.getId());
+2651 }
+2652return execution;
+2653 }
+2654
+2655/*
+2656 * Executions
+2657 */
+2658
+2659/**
+2660 * Get all running executions (for all projects)
+2661 *
+2662 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2663 * @throws RundeckApiException in case of error when calling the API
+2664 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2665 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2666 * @see #getRunningExecutions(String)
+2667 */
+2668public List<RundeckExecution> getRunningExecutions() throws RundeckApiException, RundeckApiLoginException,
+2669RundeckApiTokenException {
+2670 List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
+2671for (RundeckProject project : getProjects()) {
+2672 executions.addAll(getRunningExecutions(project.getName()));
+2673 }
+2674return executions;
+2675 }
+2676
+2677/**
+2678 * Get the running executions for the given project
+2679 *
+2680 * @param project name of the project - mandatory
+2681 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2682 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2683 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2684 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2685 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2686 * @see #getRunningExecutions()
+2687 */
+2688public List<RundeckExecution> getRunningExecutions(String project) throws RundeckApiException,
+2689 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2690 AssertUtil.notBlank(project, "project is mandatory get all running executions !");
+2691returnnewApiCall(this).get(newApiPathBuilder("/executions/running").param("project", project),
+2692new ListParser<RundeckExecution>(newExecutionParser(),
+2693"result/executions/execution"));
+2694 }
+2695
+2696/**
+2697 * Get the executions of the given job
+2698 *
+2699 * @param jobId identifier of the job - mandatory
+2700 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2701 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2702 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2703 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2704 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+2705 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+2706 */
+2707public List<RundeckExecution> getJobExecutions(String jobId) throws RundeckApiException, RundeckApiLoginException,
+2708 RundeckApiTokenException, IllegalArgumentException {
+2709return getJobExecutions(jobId, (ExecutionStatus) null);
+2710 }
+2711
+2712/**
+2713 * Get the executions of the given job
+2714 *
+2715 * @param jobId identifier of the job - mandatory
+2716 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+2717 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2718 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2719 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2720 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2721 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
+2722 * invalid
+2723 * @see #getJobExecutions(String, String, Long, Long)
+2724 */
+2725public List<RundeckExecution> getJobExecutions(String jobId, String status) throws RundeckApiException,
+2726 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2727return getJobExecutions(jobId,
+2728 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)));
+2729 }
+2730
+2731/**
+2732 * Get the executions of the given job
+2733 *
+2734 * @param jobId identifier of the job - mandatory
+2735 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+2736 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2737 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2738 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2739 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2740 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+2741 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+2742 */
+2743public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status) throws RundeckApiException,
+2744 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2745return getJobExecutions(jobId, status, null, null);
+2746 }
+2747
+2748/**
+2749 * Get the executions of the given job
+2750 *
+2751 * @param jobId identifier of the job - mandatory
+2752 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+2753 * @param max number of results to return - optional (null for all)
+2754 * @param offset the 0-indexed offset for the first result to return - optional
+2755 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2756 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2757 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2758 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2759 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace), or the executionStatus is
+2760 * invalid
+2761 * @see #getJobExecutions(String, RundeckExecution.ExecutionStatus, Long, Long)
+2762 */
+2763public List<RundeckExecution> getJobExecutions(String jobId, String status, Long max, Long offset)
+2764throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2765return getJobExecutions(jobId,
+2766 StringUtils.isBlank(status) ? null : ExecutionStatus.valueOf(StringUtils.upperCase(status)),
+2767 max,
+2768 offset);
+2769 }
+2770
+2771/**
+2772 * Get the executions of the given job
+2773 *
+2774 * @param jobId identifier of the job - mandatory
+2775 * @param status of the executions, see {@link ExecutionStatus} - optional (null for all)
+2776 * @param max number of results to return - optional (null for all)
+2777 * @param offset the 0-indexed offset for the first result to return - optional
+2778 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2779 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2780 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2781 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2782 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+2783 */
+2784public List<RundeckExecution> getJobExecutions(String jobId, ExecutionStatus status, Long max, Long offset)
+2785throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2786 AssertUtil.notBlank(jobId, "jobId is mandatory to get the executions of a job !");
+2787returnnewApiCall(this).get(newApiPathBuilder("/job/", jobId, "/executions").param("status", status)
+2788 .param("max", max)
+2789 .param("offset", offset),
+2790new ListParser<RundeckExecution>(newExecutionParser(),
+2791"result/executions/execution"));
+2792 }
+2793
+2794/**
+2795 * Get executions based on query parameters
+2796 *
+2797 * @param query query parameters for the request
+2798 * @param max number of results to return - optional (null for all)
+2799 * @param offset the 0-indexed offset for the first result to return - optional
+2800 * @return a {@link List} of {@link RundeckExecution} : might be empty, but won't be null
+2801 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+2802 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2803 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2804 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+2805 */
+2806public PagedResults<RundeckExecution> getExecutions(ExecutionQuery query, Long max, Long offset)
+2807throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2808if (!query.notBlank()) {
+2809thrownew IllegalArgumentException("Some execution query parameter must be set");
+2810 }
+2811 AssertUtil.notBlank(query.getProject(), "project is required for execution query");
+2812returnnewApiCall(this).get(newApiPathBuilder("/executions")
+2813 .param(newExecutionQueryParameters(query))
+2814 .param("max", max)
+2815 .param("offset", offset),
+2816new PagedResultParser<RundeckExecution>(
+2817new ListParser<RundeckExecution>(newExecutionParser(), "execution"),
+2818"result/executions"
+2819 )
+2820 );
+2821 }
+2822
+2823/**
+2824 * Get a single execution, identified by the given ID
+2825 *
+2826 * @param executionId identifier of the execution - mandatory
+2827 * @return a {@link RundeckExecution} instance - won't be null
+2828 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
+2829 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2830 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2831 * @throws IllegalArgumentException if the executionId is null
+2832 */
+2833publicRundeckExecution getExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
+2834 RundeckApiTokenException, IllegalArgumentException {
+2835 AssertUtil.notNull(executionId, "executionId is mandatory to get the details of an execution !");
+2836returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString()),
+2837newExecutionParser("result/executions/execution"));
+2838 }
+2839
+2840/**
+2841 * Abort an execution (identified by the given ID). The execution should be running...
+2842 *
+2843 * @param executionId identifier of the execution - mandatory
+2844 * @return a {@link RundeckAbort} instance - won't be null
+2845 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
+2846 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2847 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2848 * @throws IllegalArgumentException if the executionId is null
+2849 */
+2850publicRundeckAbort abortExecution(Long executionId) throws RundeckApiException, RundeckApiLoginException,
+2851 RundeckApiTokenException, IllegalArgumentException {
+2852return abortExecution(executionId, null);
+2853 }
+2854/**
+2855 * Abort an execution (identified by the given ID). The execution should be running...
+2856 *
+2857 * @param executionId identifier of the execution - mandatory
+2858 * @param asUser specify a user name to abort the job as, must have 'killAs' permission
+2859 * @return a {@link RundeckAbort} instance - won't be null
+2860 * @throws RundeckApiException in case of error when calling the API (non-existent execution with this ID)
+2861 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2862 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2863 * @throws IllegalArgumentException if the executionId is null
+2864 */
+2865publicRundeckAbort abortExecution(Long executionId, final String asUser) throws RundeckApiException, RundeckApiLoginException,
+2866 RundeckApiTokenException, IllegalArgumentException {
+2867 AssertUtil.notNull(executionId, "executionId is mandatory to abort an execution !");
+2868ApiPathBuilder apiPath = newApiPathBuilder("/execution/", executionId.toString(), "/abort");
+2869if(null!=asUser) {
+2870 apiPath.param("asUser", asUser);
+2871 }
+2872returnnewApiCall(this).get(apiPath, newAbortParser("result/abort"));
+2873 }
+2874
+2875/*
+2876 * History
+2877 */
+2878
+2879/**
+2880 * Get the (events) history for the given project
+2881 *
+2882 * @param project name of the project - mandatory
+2883 * @return a {@link RundeckHistory} instance - won't be null
+2884 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2885 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2886 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2887 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2888 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2889 */
+2890publicRundeckHistory getHistory(String project) throws RundeckApiException, RundeckApiLoginException,
+2891 RundeckApiTokenException, IllegalArgumentException {
+2892return getHistory(project, null, null,(String) null, (String) null, null, null, null, null);
+2893 }
+2894
+2895/**
+2896 * Get the (events) history for the given project
+2897 *
+2898 * @param project name of the project - mandatory
+2899 * @param max number of results to return - optional (default to 20)
+2900 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2901 * @return a {@link RundeckHistory} instance - won't be null
+2902 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2903 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2904 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2905 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2906 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2907 */
+2908publicRundeckHistory getHistory(String project, Long max, Long offset) throws RundeckApiException,
+2909 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2910return getHistory(project, null, null, (String)null, (String)null, null, null, max, offset);
+2911 }
+2912
+2913/**
+2914 * Get the (events) history for the given project
+2915 *
+2916 * @param project name of the project - mandatory
+2917 * @param jobId include only events matching the given job ID - optional
+2918 * @param reportId include only events matching the given report ID - optional
+2919 * @param user include only events created by the given user - optional
+2920 * @return a {@link RundeckHistory} instance - won't be null
+2921 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2922 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2923 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2924 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2925 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2926 */
+2927publicRundeckHistory getHistory(String project, String jobId, String reportId, String user)
+2928throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2929return getHistory(project, jobId, reportId, user, null, null, null, null, null);
+2930 }
+2931
+2932/**
+2933 * Get the (events) history for the given project
+2934 *
+2935 * @param project name of the project - mandatory
+2936 * @param jobId include only events matching the given job ID - optional
+2937 * @param reportId include only events matching the given report ID - optional
+2938 * @param user include only events created by the given user - optional
+2939 * @param max number of results to return - optional (default to 20)
+2940 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2941 * @return a {@link RundeckHistory} instance - won't be null
+2942 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2943 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2944 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2945 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2946 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2947 */
+2948publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, Long max, Long offset)
+2949throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2950return getHistory(project, jobId, reportId, user, null, null, null, max, offset);
+2951 }
+2952
+2953/**
+2954 * Get the (events) history for the given project
+2955 *
+2956 * @param project name of the project - mandatory
+2957 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+2958 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+2959 * weeks), "5d" (= last 5 days), etc. Optional.
+2960 * @return a {@link RundeckHistory} instance - won't be null
+2961 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2962 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2963 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2964 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2965 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2966 */
+2967publicRundeckHistory getHistory(String project, String recent) throws RundeckApiException,
+2968 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2969return getHistory(project, null, null, null, recent, null, null, null, null);
+2970 }
+2971
+2972/**
+2973 * Get the (events) history for the given project
+2974 *
+2975 * @param project name of the project - mandatory
+2976 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+2977 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+2978 * weeks), "5d" (= last 5 days), etc. Optional.
+2979 * @param max number of results to return - optional (default to 20)
+2980 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+2981 * @return a {@link RundeckHistory} instance - won't be null
+2982 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+2983 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+2984 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+2985 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+2986 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+2987 */
+2988publicRundeckHistory getHistory(String project, String recent, Long max, Long offset) throws RundeckApiException,
+2989 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+2990return getHistory(project, null, null, null, recent, null, null, max, offset);
+2991 }
+2992
+2993/**
+2994 * Get the (events) history for the given project
+2995 *
+2996 * @param project name of the project - mandatory
+2997 * @param begin date for the earlier events to retrieve - optional
+2998 * @param end date for the latest events to retrieve - optional
+2999 * @return a {@link RundeckHistory} instance - won't be null
+3000 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3001 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3002 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3003 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3004 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+3005 */
+3006publicRundeckHistory getHistory(String project, Date begin, Date end) throws RundeckApiException,
+3007 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3008return getHistory(project, null, null, (String)null, (String)null, begin, end, null, null);
+3009 }
+3010
+3011/**
+3012 * Get the (events) history for the given project
+3013 *
+3014 * @param project name of the project - mandatory
+3015 * @param begin date for the earlier events to retrieve - optional
+3016 * @param end date for the latest events to retrieve - optional
+3017 * @param max number of results to return - optional (default to 20)
+3018 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+3019 * @return a {@link RundeckHistory} instance - won't be null
+3020 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3021 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3022 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3023 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3024 * @see #getHistory(String, String, String, String, String, Date, Date, Long, Long)
+3025 */
+3026publicRundeckHistory getHistory(String project, Date begin, Date end, Long max, Long offset)
+3027throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3028return getHistory(project, null, null, (String)null, (String) null, begin, end, max, offset);
+3029 }
+3030
+3031/**
+3032 * Get the (events) history for the given project
+3033 *
+3034 * @param project name of the project - mandatory
+3035 * @param jobId include only events matching the given job ID - optional
+3036 * @param reportId include only events matching the given report ID - optional
+3037 * @param user include only events created by the given user - optional
+3038 * @param recent include only events matching the given period of time. Format : "XY", where X is an integer, and Y
+3039 * is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year). Example : "2w" (= last 2
+3040 * weeks), "5d" (= last 5 days), etc. Optional.
+3041 * @param begin date for the earlier events to retrieve - optional
+3042 * @param end date for the latest events to retrieve - optional
+3043 * @param max number of results to return - optional (default to 20)
+3044 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+3045 * @return a {@link RundeckHistory} instance - won't be null
+3046 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3047 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3048 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3049 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3050 */
+3051publicRundeckHistory getHistory(String project, String jobId, String reportId, String user, String recent,
+3052 Date begin, Date end, Long max, Long offset) throws RundeckApiException, RundeckApiLoginException,
+3053 RundeckApiTokenException, IllegalArgumentException {
+3054 AssertUtil.notBlank(project, "project is mandatory to get the history !");
+3055returnnewApiCall(this).get(newApiPathBuilder("/history").param("project", project)
+3056 .param("jobIdFilter", jobId)
+3057 .param("reportIdFilter", reportId)
+3058 .param("userFilter", user)
+3059 .param("recentFilter", recent)
+3060 .param("begin", begin)
+3061 .param("end", end)
+3062 .param("max", max)
+3063 .param("offset", offset),
+3064newHistoryParser("result/events"));
+3065 }
+3066
+3067/**
+3068 * Get the (events) history for the given project
+3069 *
+3070 * @param project name of the project - mandatory
+3071 * @param includeJobNames list of job names ("group/name") to include results for
+3072 * @param excludeJobNames list of job names ("group/name") to exclude results for
+3073 * @param user include only events created by the given user - optional
+3074 * @param recent include only events matching the given period of time. Format : "XY", where X is an
+3075 * integer, and Y is one of : "h" (hour), "d" (day), "w" (week), "m" (month), "y" (year).
+3076 * Example : "2w" (= last 2 weeks), "5d" (= last 5 days), etc. Optional.
+3077 * @param begin date for the earlier events to retrieve - optional
+3078 * @param end date for the latest events to retrieve - optional
+3079 * @param max number of results to return - optional (default to 20)
+3080 * @param offset the 0-indexed offset for the first result to return - optional (default to O)
+3081 *
+3082 * @return a {@link RundeckHistory} instance - won't be null
+3083 *
+3084 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3085 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3086 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3087 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3088 */
+3089publicRundeckHistory getHistory(String project,
+3090 String user,
+3091 String recent,
+3092 List<String> includeJobNames,
+3093 List<String> excludeJobNames,
+3094 Date begin,
+3095 Date end,
+3096 Long max,
+3097 Long offset)
+3098throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3099
+3100 AssertUtil.notBlank(project, "project is mandatory to get the history !");
+3101finalApiPathBuilder builder = newApiPathBuilder("/history").param("project", project)
+3102 .field("jobListFilter", includeJobNames)
+3103 .field("excludeJobListFilter", excludeJobNames)
+3104 .param("userFilter", user)
+3105 .param("recentFilter", recent)
+3106 .param("begin", begin)
+3107 .param("end", end)
+3108 .param("max", max)
+3109 .param("offset", offset);
+3110
+3111returnnewApiCall(this).postOrGet(builder, newHistoryParser("result/events"));
+3112 }
+3113
+3114/*
+3115 * Nodes
+3116 */
+3117
+3118/**
+3119 * List all nodes (for all projects)
+3120 *
+3121 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+3122 * @throws RundeckApiException in case of error when calling the API
+3123 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3124 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3125 */
+3126public List<RundeckNode> getNodes() throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException {
+3127 List<RundeckNode> nodes = new ArrayList<RundeckNode>();
+3128for (RundeckProject project : getProjects()) {
+3129 nodes.addAll(getNodes(project.getName()));
+3130 }
+3131return nodes;
+3132 }
+3133
+3134/**
+3135 * List all nodes that belongs to the given project
+3136 *
+3137 * @param project name of the project - mandatory
+3138 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+3139 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3140 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3141 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3142 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3143 * @see #getNodes(String, Properties)
+3144 */
+3145public List<RundeckNode> getNodes(String project) throws RundeckApiException, RundeckApiLoginException,
+3146 RundeckApiTokenException, IllegalArgumentException {
+3147return getNodes(project, null);
+3148 }
+3149
+3150/**
+3151 * List nodes that belongs to the given project
+3152 *
+3153 * @param project name of the project - mandatory
+3154 * @param nodeFilters for filtering the nodes - optional. See {@link NodeFiltersBuilder}
+3155 * @return a {@link List} of {@link RundeckNode} : might be empty, but won't be null
+3156 * @throws RundeckApiException in case of error when calling the API (non-existent project with this name)
+3157 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3158 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3159 * @throws IllegalArgumentException if the project is blank (null, empty or whitespace)
+3160 */
+3161public List<RundeckNode> getNodes(String project, Properties nodeFilters) throws RundeckApiException,
+3162 RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3163 AssertUtil.notBlank(project, "project is mandatory to get all nodes !");
+3164returnnewApiCall(this).get(newApiPathBuilder("/resources").param("project", project)
+3165 .nodeFilters(nodeFilters),
+3166new ListParser<RundeckNode>(newNodeParser(), "project/node"));
+3167 }
+3168
+3169/**
+3170 * Get the definition of a single node
+3171 *
+3172 * @param name of the node - mandatory
+3173 * @param project name of the project - mandatory
+3174 * @return a {@link RundeckNode} instance - won't be null
+3175 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
+3176 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3177 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3178 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+3179 */
+3180publicRundeckNode getNode(String name, String project) throws RundeckApiException, RundeckApiLoginException,
+3181 RundeckApiTokenException, IllegalArgumentException {
+3182 AssertUtil.notBlank(name, "the name of the node is mandatory to get a node !");
+3183 AssertUtil.notBlank(project, "project is mandatory to get a node !");
+3184returnnewApiCall(this).get(newApiPathBuilder("/resource/", name).param("project", project),
+3185newNodeParser("project/node"));
+3186 }
+3187
+3188/**
+3189 * Get the output of a job execution
+3190 *
+3191 * @param executionId id of the execution - mandatory
+3192 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+3193 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
+3194 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3195 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3196 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+3197 */
+3198public InputStream getOutput(String executionId) throws RundeckApiException, RundeckApiLoginException,
+3199 RundeckApiTokenException, IllegalArgumentException {
+3200 AssertUtil.notBlank(executionId, "the execution id is mandatory to get execution output !");
+3201returnnewApiCall(this).getNonApi(newApiPathBuilder("/execution/downloadOutput/", executionId));
+3202 }
+3203
+3204/**
+3205 * Get the html page of the user's profile
+3206 *
+3207 * @param username - mandatory
+3208 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+3209 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
+3210 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3211 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3212 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+3213 */
+3214public InputStream getProfilePage(String username) throws RundeckApiException, RundeckApiLoginException,
+3215 RundeckApiTokenException, IllegalArgumentException {
+3216 AssertUtil.notBlank(username, "the username is mandatory to get profile page !");
+3217returnnewApiCall(this).getNonApi(newApiPathBuilder("/user/profile?login=", username));
+3218 }
+3219
+3220
+3221/**
+3222 * Generate a new token and get the result page (which is the html page of the user's profile)
+3223 *
+3224 * @param username - mandatory
+3225 * @return an {@link InputStream} instance, not linked to any network resources - won't be null
+3226 * @throws RundeckApiException in case of error when calling the API (non-existent name or project with this name)
+3227 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3228 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3229 * @throws IllegalArgumentException if the name or project is blank (null, empty or whitespace)
+3230 */
+3231public InputStream generateToken(String username) throws RundeckApiException, RundeckApiLoginException,
+3232 RundeckApiTokenException, IllegalArgumentException {
+3233 AssertUtil.notBlank(username, "the username is mandatory to generate the token");
+3234returnnewApiCall(this).getNonApi(newApiPathBuilder("/user/generateApiToken?login=", username));
+3235 }
+3236
+3237
+3238/**
+3239 * Get the execution output of the given job
+3240 *
+3241 * @param executionId identifier of the execution - mandatory
+3242 * @param offset byte offset to read from in the file. 0 indicates the beginning.
+3243 * @param lastlines nnumber of lines to retrieve from the end of the available output. If specified it will override the offset value and return only the specified number of lines at the end of the log.
+3244 * @param lastmod epoch datestamp in milliseconds, return results only if modification changed since the specified date OR if more data is available at the given offset
+3245 * @param maxlines maximum number of lines to retrieve forward from the specified offset.
+3246 * @return {@link RundeckOutput}
+3247 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+3248 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3249 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3250 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+3251 */
+3252publicRundeckOutput getJobExecutionOutput(Long executionId, int offset, int lastlines, long lastmod, int maxlines)
+3253throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3254 AssertUtil.notNull(executionId, "executionId is mandatory to get the output of a job execution!");
+3255returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/output.xml").param("offset", offset)
+3256 .param("lastlines", lastlines)
+3257 .param("lastmod", lastmod)
+3258 .param("maxlines", maxlines),
+3259newOutputParser("result/output", createOutputEntryParser()));
+3260 }
+3261
+3262
+3263/**
+3264 * Get the execution output of the given job
+3265 *
+3266 * @param executionId identifier of the execution - mandatory
+3267 * @param offset byte offset to read from in the file. 0 indicates the beginning.
+3268 * @param lastmod epoch datestamp in milliseconds, return results only if modification changed since the specified date OR if more data is available at the given offset
+3269 * @param maxlines maximum number of lines to retrieve forward from the specified offset.
+3270 * @return {@link RundeckOutput}
+3271 * @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
+3272 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3273 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3274 * @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
+3275 */
+3276publicRundeckOutput getJobExecutionOutput(Long executionId, int offset, long lastmod, int maxlines)
+3277throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
+3278 AssertUtil.notNull(executionId, "executionId is mandatory to get the output of a job execution!");
+3279returnnewApiCall(this).get(newApiPathBuilder("/execution/", executionId.toString(), "/output.xml").param("offset", offset)
+3280 .param("lastmod", lastmod)
+3281 .param("maxlines", maxlines),
+3282newOutputParser("result/output", createOutputEntryParser()));
+3283 }
+3284
+3285privateOutputEntryParser createOutputEntryParser() {
+3286if (getApiVersion() <= Version.V5.versionNumber) {
+3287returnnewOutputEntryParserV5();
+3288 }else{
+3289returnnewOutputEntryParser();
+3290 }
+3291 }
+3292
+3293
+3294/*
+3295 * System Info
+3296 */
+3297
+3298/**
+3299 * Get system informations about the RunDeck server
+3300 *
+3301 * @return a {@link RundeckSystemInfo} instance - won't be null
+3302 * @throws RundeckApiException in case of error when calling the API
+3303 * @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
+3304 * @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
+3305 */
+3306publicRundeckSystemInfo getSystemInfo() throws RundeckApiException, RundeckApiLoginException,
+3307RundeckApiTokenException {
+3308returnnewApiCall(this).get(newApiPathBuilder("/system/info"), newSystemInfoParser("result/system"));
+3309 }
+3310
+3311/**
+3312 * @return the URL of the RunDeck instance ("http://localhost:4440", "http://rundeck.your-compagny.com/", etc)
+3313 */
+3314public String getUrl() {
+3315return url;
+3316 }
+3317
+3318/**
+3319 * @return the auth-token used for authentication on the RunDeck instance (null if using login-based or session-based auth)
+3320 */
+3321public String getToken() {
+3322return token;
+3323 }
+3324
+3325/**
+3326 * @return the login used for authentication on the RunDeck instance (null if using token-based or session-based auth)
+3327 */
+3328public String getLogin() {
+3329return login;
+3330 }
+3331
+3332/**
+3333 * @return the password used for authentication on the RunDeck instance (null if using token-based or session-based auth)
+3334 */
+3335public String getPassword() {
+3336return password;
+3337 }
+3338
+3339/**
+3340 * @return the sessionID used for authentication on the RunDeck instance (null if using login-based or token-based auth)
+3341 */
+3342public String getSessionID() {
+3343return sessionID;
+3344 }
+3345
+3346 @Override
+3347public String toString() {
+3348 StringBuilder str = new StringBuilder();
+3349 str.append("RundeckClient ").append(API_VERSION);
+3350 str.append(" [").append(url).append("] ");
+3351if (token != null) {
+3352 str.append("(token=").append(token).append(")");
+3353 } else {
+3354 str.append("(credentials=").append(login).append("|").append(password).append(")");
+3355 }
+3356return str.toString();
+3357 }
+3358
+3359 @Override
+3360publicint hashCode() {
+3361finalint prime = 31;
+3362int result = 1;
+3363 result = prime * result + ((login == null) ? 0 : login.hashCode());
+3364 result = prime * result + ((password == null) ? 0 : password.hashCode());
+3365 result = prime * result + ((token == null) ? 0 : token.hashCode());
+3366 result = prime * result + ((url == null) ? 0 : url.hashCode());
+3367return result;
+3368 }
+3369
+3370 @Override
+3371publicboolean equals(Object obj) {
+3372if (this == obj)
+3373returntrue;
+3374if (obj == null)
+3375return false;
+3376if (getClass() != obj.getClass())
+3377return false;
+3378RundeckClient other = (RundeckClient) obj;
+3379if (login == null) {
+3380if (other.login != null)
+3381return false;
+3382 } elseif (!login.equals(other.login))
+3383return false;
+3384if (password == null) {
+3385if (other.password != null)
+3386return false;
+3387 } elseif (!password.equals(other.password))
+3388return false;
+3389if (token == null) {
+3390if (other.token != null)
+3391return false;
+3392 } elseif (!token.equals(other.token))
+3393return false;
+3394if (url == null) {
+3395if (other.url != null)
+3396return false;
+3397 } elseif (!url.equals(other.url))
+3398return false;
+3399returntrue;
+3400 }
+3401
+3402 }
diff --git a/xref/org/rundeck/api/RundeckClientBuilder.html b/xref/org/rundeck/api/RundeckClientBuilder.html
index b0c4452..707e237 100644
--- a/xref/org/rundeck/api/RundeckClientBuilder.html
+++ b/xref/org/rundeck/api/RundeckClientBuilder.html
@@ -14,7 +14,7 @@
456/**
-7 * Builder to create a {@link RundeckClient}, you must specify a url, and at least one of (login, password), token, or
+7 * Builder to build a {@link RundeckClient}, you must specify a url, and at least one of (login, password), token, or8 * sessionId.9 */10publicclassRundeckClientBuilder {
diff --git a/xref/org/rundeck/api/RundeckJobsImport.html b/xref/org/rundeck/api/RundeckJobsImport.html
new file mode 100644
index 0000000..d03c90e
--- /dev/null
+++ b/xref/org/rundeck/api/RundeckJobsImport.html
@@ -0,0 +1,48 @@
+
+
+
+
+RundeckJobsImport xref
+
+
+
+