mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-08 05:58:39 +00:00
Compare commits
95 commits
rundeck-ap
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
4d49ef39bd | ||
|
a299c12c39 | ||
|
d612f3c88b | ||
|
19527ea325 | ||
|
68717ae864 | ||
|
5bf4be0bc8 | ||
|
92d15c0748 | ||
|
eeaf4a3944 | ||
|
008a8c3ce4 | ||
|
c1a1f3c365 | ||
|
b3839f089b | ||
|
ea5f82714d | ||
|
e548d640c0 | ||
|
e98a3a0ad9 | ||
|
1f2ffeebac | ||
|
39fd86ae6d | ||
|
bceb1ec4c6 | ||
|
8cc48ecd89 | ||
|
c8e1315612 | ||
|
18ec800264 | ||
|
f133c04a02 | ||
|
7bad157911 | ||
|
3219161dd3 | ||
|
75231805ec | ||
|
3d60907013 | ||
|
d7928bc37e | ||
|
7228205e57 | ||
|
e73bb27058 | ||
|
e2839d6244 | ||
|
40f5c5b891 | ||
|
a598c76d8e | ||
|
e092ccdb13 | ||
|
b1c0a45da6 | ||
|
a7c0c22699 | ||
|
bbe599b915 | ||
|
7b6259b66b | ||
|
d3cad78f3d | ||
|
663d1c2366 | ||
|
7146aca129 | ||
|
0191bd34ff | ||
|
a59246bdf3 | ||
|
89452e731a | ||
|
459b498d35 | ||
|
c7153a5613 | ||
|
0f8e338719 | ||
|
0cb3da88ec | ||
|
b5f4ec8ccd | ||
|
c12b2f1459 | ||
|
69d9c91ef8 | ||
|
97fa962311 | ||
|
bea99b1c97 | ||
|
2ffe87d428 | ||
|
e8672e025b | ||
|
f49aa63043 | ||
|
29459d9ee1 | ||
|
e548c14b24 | ||
|
92eb7acc15 | ||
|
b571c2a5be | ||
|
303a3dec57 | ||
|
7543d5d630 | ||
|
bd7e8f5cec | ||
|
c3b1cbc39f | ||
|
9ebd63e953 | ||
|
7aa512f1ac | ||
|
e95892e88e | ||
|
8a495f8723 | ||
|
ee9e4f3c54 | ||
|
ec439560b5 | ||
|
bf13167363 | ||
|
7409d30d93 | ||
|
f84ddd6ad8 | ||
|
b1c15fc07b | ||
|
1a1e610b20 | ||
|
6c1f93af49 | ||
|
ba136cfc44 | ||
|
cbdb5c818e | ||
|
d29d2067d0 | ||
|
6b2b7954d3 | ||
|
ad49b635b7 | ||
|
cb4d67f8f4 | ||
|
8e59972a79 | ||
|
aba9f8de2b | ||
|
af37fd1f56 | ||
|
9ca85e810f | ||
|
e3291e3dab | ||
|
eb392dd32e | ||
|
9f8bf879ff | ||
|
962acecabb | ||
|
4027040e95 | ||
|
3cf156dea8 | ||
|
b554f9bc73 | ||
|
aa60a9fc56 | ||
|
aee7b2edac | ||
|
b08edf9010 | ||
|
deee2ac0b1 |
141 changed files with 7654 additions and 1962 deletions
1
.travis.yml
Normal file
1
.travis.yml
Normal file
|
@ -0,0 +1 @@
|
|||
language: java
|
13
dependencies-check-rules.xml
Normal file
13
dependencies-check-rules.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<ruleset comparisonMethod="maven"
|
||||
xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
|
||||
|
||||
<!--Ignore alpha, beta, release-candidate and draft versions-->
|
||||
<ignoreVersions>
|
||||
<ignoreVersion type="regex">.*[\.-](?i)alpha[0-9]*$</ignoreVersion>
|
||||
<ignoreVersion type="regex">.*[\.-](?i)b(eta)?-?[0-9]*$</ignoreVersion>
|
||||
<ignoreVersion type="regex">.*[\.-](?i)rc?[0-9]*$</ignoreVersion>
|
||||
<ignoreVersion type="regex">.*[\.-](?i)draft.*$</ignoreVersion>
|
||||
</ignoreVersions>
|
||||
</ruleset>
|
3
mvn.sh
Executable file
3
mvn.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=192m" exec mvn "$@"
|
38
pom.xml
38
pom.xml
|
@ -17,6 +17,10 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<!-- For deploying to Sonatype OSS Nexus -->
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
|
@ -27,7 +31,7 @@
|
|||
<!-- Project informations -->
|
||||
<groupId>org.rundeck</groupId>
|
||||
<artifactId>rundeck-api-java-client</artifactId>
|
||||
<version>9.1</version>
|
||||
<version>12.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>RunDeck API - Java Client</name>
|
||||
<description>Java client for the RunDeck REST API</description>
|
||||
|
@ -88,6 +92,16 @@
|
|||
<project.build.targetJdk>1.6</project.build.targetJdk>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<!-- Dependencies version -->
|
||||
<apache.httpcomponents.version>4.3.6</apache.httpcomponents.version>
|
||||
<commons-lang.version>2.6</commons-lang.version>
|
||||
<commons-io.version>2.1</commons-io.version>
|
||||
<dom4j.version>1.6.1</dom4j.version>
|
||||
<jaxen.version>1.1.1</jaxen.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
<betamax.version>1.0</betamax.version>
|
||||
<groovy.version>1.8.4</groovy.version>
|
||||
|
||||
<!-- Plugins version -->
|
||||
<plugin.antrun.version>1.7</plugin.antrun.version>
|
||||
<plugin.assembly.version>2.2.2</plugin.assembly.version>
|
||||
|
@ -114,7 +128,7 @@
|
|||
<plugin.source.version>2.1.2</plugin.source.version>
|
||||
<plugin.surefire.version>2.10</plugin.surefire.version>
|
||||
<plugin.taglist.version>2.4</plugin.taglist.version>
|
||||
<plugin.versions.version>1.2</plugin.versions.version>
|
||||
<plugin.versions.version>2.1</plugin.versions.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -392,7 +406,7 @@
|
|||
</reportSet>
|
||||
</reportSets>
|
||||
<configuration>
|
||||
<comparisonMethod>mercury</comparisonMethod>
|
||||
<rulesUri>file:./dependencies-check-rules.xml</rulesUri>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -423,52 +437,52 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<version>${apache.httpcomponents.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<version>${apache.httpcomponents.version}</version>
|
||||
</dependency>
|
||||
<!-- Commons -->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<version>${commons-lang.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.1</version>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<!-- XML Parsing -->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<version>${dom4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<version>${jaxen.version}</version>
|
||||
</dependency>
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.robfletcher</groupId>
|
||||
<artifactId>betamax</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>${betamax.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>1.8.4</version>
|
||||
<version>${groovy.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -19,9 +19,69 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
|
||||
<properties>
|
||||
<title>Changelog</title>
|
||||
<author>Vincent Behar</author>
|
||||
<author>Greg Schueler</author>
|
||||
</properties>
|
||||
<body>
|
||||
<release date='2014-11-25' description='Rundeck API version 12' version='12.0'>
|
||||
<action type='fix' dev='Sylvain-Bugat'>
|
||||
Pull Request #18: OWASP A9 fix know vulnerabilities: CVE-2014-3577: in Apache
|
||||
HttpComponents HttpClient before 4.3.5.
|
||||
</action>
|
||||
<action type='add' dev='gschueler'>
|
||||
Add API v12 support
|
||||
</action>
|
||||
<action type='fix' dev='gschueler'>
|
||||
Issue #17: Handle incorrect API v11 responses
|
||||
</action>
|
||||
</release>
|
||||
<release date='2014-11-06' description='Bugfix' version='11.1'>
|
||||
<action type='fix' dev='gschueler'>
|
||||
Issue #14: deleteJob fails
|
||||
</action>
|
||||
</release>
|
||||
<release date='2014-04-24' description='Rundeck API version 11' version='11.0'>
|
||||
<action type='add' dev='gschueler'>Project creation</action>
|
||||
<action type='add' dev='gschueler'>Get Project configuration</action>
|
||||
<action type='add' dev='gschueler'>Set Project configuration</action>
|
||||
<action type='add' dev='gschueler'>Get/Set Project configuration keys</action>
|
||||
<action type='add' dev='gschueler'>Delete project</action>
|
||||
<action type='add' dev='gschueler'>Export project archive</action>
|
||||
<action type='add' dev='gschueler'>Import project archive</action>
|
||||
<action type='add' dev='gschueler'>Key file upload</action>
|
||||
<action type='add' dev='gschueler'>Key file delete</action>
|
||||
<action type='add' dev='gschueler'>Key file list</action>
|
||||
<action type='add' dev='gschueler'>Key file get</action>
|
||||
<action type='add' dev='gschueler'>API Token create</action>
|
||||
<action type='add' dev='gschueler'>API Token list</action>
|
||||
<action type='add' dev='gschueler'>API Token delete</action>
|
||||
</release>
|
||||
<release date='2014-02-27' description='Rundeck API version 10' version='10.0'>
|
||||
<action type='add' dev='gschueler'>
|
||||
Execution State - Retrieve workflow step and node state information
|
||||
</action>
|
||||
<action type='add' dev='gschueler'>
|
||||
Execution Output with State - Retrieve log output with state change information
|
||||
</action>
|
||||
<action type='add' dev='gschueler'>
|
||||
Execution Output - Retrieve log output for a particular node or step.
|
||||
</action>
|
||||
<action type='add' dev='gschueler'>
|
||||
Execution Info - added successfulNodes and failedNodes detail.
|
||||
</action>
|
||||
<action type='remove' dev='gschueler'>
|
||||
Remove deprecated RundeckClient methods.
|
||||
</action>
|
||||
</release>
|
||||
<release date='2014-01-24' description='Bugfix' version='9.3'>
|
||||
<action type='fix' dev='gschueler'>
|
||||
Issue #7: Fix authentication to Tomcat container (thanks @katanafleet)
|
||||
</action>
|
||||
</release>
|
||||
<release date='2014-01-23' description='Bugfix' version='9.2'>
|
||||
<action type='fix' dev='gschueler'>
|
||||
Bugfix. If apiVersion is set to 0, request defaults to current API version.
|
||||
</action>
|
||||
</release>
|
||||
<release date='2014-01-16' description='Complete Rundeck API version 9' version='9.1'>
|
||||
<action type='add' dev='gschueler'>
|
||||
Add uuidOption support to jobs import, API v9
|
||||
|
|
|
@ -15,23 +15,18 @@
|
|||
*/
|
||||
package org.rundeck.api;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpException;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpRequestInterceptor;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.ParseException;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.entity.BasicHttpEntity;
|
||||
import org.apache.http.entity.EntityTemplate;
|
||||
import org.apache.http.entity.FileEntity;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntity;
|
||||
import org.apache.http.entity.mime.content.InputStreamBody;
|
||||
|
@ -42,17 +37,14 @@ import org.apache.http.params.HttpProtocolParams;
|
|||
import org.apache.http.protocol.HTTP;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
|
||||
import org.rundeck.api.RundeckApiException.RundeckApiTokenException;
|
||||
import org.rundeck.api.parser.ParserHelper;
|
||||
import org.rundeck.api.parser.XmlNodeParser;
|
||||
import org.rundeck.api.util.AssertUtil;
|
||||
import org.rundeck.api.util.DocumentContentProducer;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.ProxySelector;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
|
@ -66,7 +58,7 @@ import java.util.Map.Entry;
|
|||
|
||||
/**
|
||||
* Class responsible for making the HTTP API calls
|
||||
*
|
||||
*
|
||||
* @author Vincent Behar
|
||||
*/
|
||||
class ApiCall {
|
||||
|
@ -79,10 +71,10 @@ class ApiCall {
|
|||
|
||||
/** {@link RundeckClient} instance holding the RunDeck url and the credentials */
|
||||
private final RundeckClient client;
|
||||
|
||||
|
||||
/**
|
||||
* Build a new instance, linked to the given RunDeck client
|
||||
*
|
||||
*
|
||||
* @param client holding the RunDeck url and the credentials
|
||||
* @throws IllegalArgumentException if client is null
|
||||
*/
|
||||
|
@ -94,7 +86,7 @@ class ApiCall {
|
|||
|
||||
/**
|
||||
* Try to "ping" the RunDeck instance to see if it is alive
|
||||
*
|
||||
*
|
||||
* @throws RundeckApiException if the ping fails
|
||||
*/
|
||||
public void ping() throws RundeckApiException {
|
||||
|
@ -115,7 +107,8 @@ class ApiCall {
|
|||
/**
|
||||
* Test the authentication on the RunDeck instance. Will delegate to either {@link #testLoginAuth()} (in case of
|
||||
* login-based auth) or {@link #testTokenAuth()} (in case of token-based auth).
|
||||
*
|
||||
*
|
||||
* @return the login session ID if using login-based auth, otherwise null
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
* @see #testLoginAuth()
|
||||
|
@ -133,7 +126,7 @@ class ApiCall {
|
|||
|
||||
/**
|
||||
* Test the login-based authentication on the RunDeck instance
|
||||
*
|
||||
*
|
||||
* @throws RundeckApiLoginException if the login fails
|
||||
* @see #testAuth()
|
||||
*/
|
||||
|
@ -150,7 +143,7 @@ class ApiCall {
|
|||
|
||||
/**
|
||||
* Test the token-based authentication on the RunDeck instance
|
||||
*
|
||||
*
|
||||
* @throws RundeckApiTokenException if the token is invalid
|
||||
* @see #testAuth()
|
||||
*/
|
||||
|
@ -167,7 +160,7 @@ class ApiCall {
|
|||
/**
|
||||
* Execute an HTTP GET request to the RunDeck instance, on the given path. We will login first, and then execute the
|
||||
* API call. At the end, the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @param parser used to parse the response
|
||||
* @return the result of the call, as formatted by the parser
|
||||
|
@ -177,13 +170,17 @@ class ApiCall {
|
|||
*/
|
||||
public <T> T get(ApiPathBuilder apiPath, XmlNodeParser<T> parser) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
return execute(new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath), parser);
|
||||
HttpGet request = new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath);
|
||||
if (null != apiPath.getAccept()) {
|
||||
request.setHeader("Accept", apiPath.getAccept());
|
||||
}
|
||||
return execute(request, parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an HTTP GET request to the RunDeck instance, on the given path. We will login first, and then execute the
|
||||
* API call.
|
||||
*
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @return a new {@link InputStream} instance, not linked with network resources
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
|
@ -192,7 +189,11 @@ class ApiCall {
|
|||
*/
|
||||
public InputStream get(ApiPathBuilder apiPath) throws RundeckApiException, RundeckApiLoginException,
|
||||
RundeckApiTokenException {
|
||||
ByteArrayInputStream response = execute(new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath));
|
||||
HttpGet request = new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath);
|
||||
if (null != apiPath.getAccept()) {
|
||||
request.setHeader("Accept", apiPath.getAccept());
|
||||
}
|
||||
ByteArrayInputStream response = execute(request);
|
||||
|
||||
// try to load the document, to throw an exception in case of error
|
||||
ParserHelper.loadDocument(response);
|
||||
|
@ -204,7 +205,7 @@ class ApiCall {
|
|||
/**
|
||||
* Execute an HTTP GET request to the RunDeck instance, on the given path. We will login first, and then execute the
|
||||
* API call without appending the API_ENDPOINT to the URL.
|
||||
*
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @return a new {@link InputStream} instance, not linked with network resources
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
|
@ -213,7 +214,11 @@ class ApiCall {
|
|||
*/
|
||||
public InputStream getNonApi(ApiPathBuilder apiPath) throws RundeckApiException, RundeckApiLoginException,
|
||||
RundeckApiTokenException {
|
||||
ByteArrayInputStream response = execute(new HttpGet(client.getUrl() + apiPath));
|
||||
HttpGet request = new HttpGet(client.getUrl() + apiPath);
|
||||
if (null != apiPath.getAccept()) {
|
||||
request.setHeader("Accept", apiPath.getAccept());
|
||||
}
|
||||
ByteArrayInputStream response = execute(request);
|
||||
response.reset();
|
||||
|
||||
return response;
|
||||
|
@ -242,11 +247,11 @@ class ApiCall {
|
|||
return get(apiPath, parser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute an HTTP POST request to the RunDeck instance, on the given path. We will login first, and then execute
|
||||
* the API call. At the end, the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @param parser used to parse the response
|
||||
* @return the result of the call, as formatted by the parser
|
||||
|
@ -257,7 +262,30 @@ class ApiCall {
|
|||
public <T> T post(ApiPathBuilder apiPath, XmlNodeParser<T> parser) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
HttpPost httpPost = new HttpPost(client.getUrl() + client.getApiEndpoint() + apiPath);
|
||||
return requestWithEntity(apiPath, parser, httpPost);
|
||||
}
|
||||
/**
|
||||
* Execute an HTTP PUT request to the RunDeck instance, on the given path. We will login first, and then execute
|
||||
* the API call. At the end, the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @param parser used to parse the response
|
||||
* @return the result of the call, as formatted by the parser
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
*/
|
||||
public <T> T put(ApiPathBuilder apiPath, XmlNodeParser<T> parser) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
HttpPut httpPut = new HttpPut(client.getUrl() + client.getApiEndpoint() + apiPath);
|
||||
return requestWithEntity(apiPath, parser, httpPut);
|
||||
}
|
||||
|
||||
private <T> T requestWithEntity(ApiPathBuilder apiPath, XmlNodeParser<T> parser, HttpEntityEnclosingRequestBase
|
||||
httpPost) {
|
||||
if(null!= apiPath.getAccept()) {
|
||||
httpPost.setHeader("Accept", apiPath.getAccept());
|
||||
}
|
||||
// POST a multi-part request, with all attachments
|
||||
if(apiPath.getAttachments().size()>0){
|
||||
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
|
@ -271,6 +299,18 @@ class ApiCall {
|
|||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RundeckApiException("Unsupported encoding: " + e.getMessage(), e);
|
||||
}
|
||||
}else if(apiPath.getContentStream() !=null && apiPath.getContentType()!=null){
|
||||
BasicHttpEntity entity = new BasicHttpEntity();
|
||||
entity.setContent(apiPath.getContentStream());
|
||||
entity.setContentType(apiPath.getContentType());
|
||||
httpPost.setEntity(entity);
|
||||
}else if(apiPath.getContentFile() !=null && apiPath.getContentType()!=null){
|
||||
httpPost.setEntity(new FileEntity(apiPath.getContentFile(), apiPath.getContentType()));
|
||||
}else if(apiPath.getXmlDocument()!=null) {
|
||||
httpPost.setHeader("Content-Type", "application/xml");
|
||||
httpPost.setEntity(new EntityTemplate(new DocumentContentProducer(apiPath.getXmlDocument())));
|
||||
}else if(apiPath.isEmptyContent()){
|
||||
//empty content
|
||||
}else {
|
||||
throw new IllegalArgumentException("No Form or Multipart entity for POST content-body");
|
||||
}
|
||||
|
@ -281,7 +321,7 @@ class ApiCall {
|
|||
/**
|
||||
* Execute an HTTP DELETE request to the RunDeck instance, on the given path. We will login first, and then execute
|
||||
* the API call. At the end, the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @param parser used to parse the response
|
||||
* @return the result of the call, as formatted by the parser
|
||||
|
@ -293,11 +333,27 @@ class ApiCall {
|
|||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
return execute(new HttpDelete(client.getUrl() + client.getApiEndpoint() + apiPath), parser);
|
||||
}
|
||||
/**
|
||||
* Execute an HTTP DELETE request to the RunDeck instance, on the given path, and expect a 204 response.
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
*/
|
||||
public void delete(ApiPathBuilder apiPath) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
|
||||
InputStream response = execute(new HttpDelete(client.getUrl() + client.getApiEndpoint() + apiPath));
|
||||
if(null!=response){
|
||||
throw new RundeckApiException("Unexpected Rundeck response content, expected no content!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an HTTP request to the RunDeck instance. We will login first, and then execute the API call. At the end,
|
||||
* the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
*
|
||||
* @param request to execute. see {@link HttpGet}, {@link HttpDelete}, and so on...
|
||||
* @param parser used to parse the response
|
||||
* @return the result of the call, as formatted by the parser
|
||||
|
@ -308,23 +364,171 @@ class ApiCall {
|
|||
private <T> T execute(HttpRequestBase request, XmlNodeParser<T> parser) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException {
|
||||
// execute the request
|
||||
InputStream response = execute(request);
|
||||
|
||||
// read and parse the response
|
||||
Document xmlDocument = ParserHelper.loadDocument(response);
|
||||
return parser.parseXmlNode(xmlDocument);
|
||||
return new ParserHandler<T>(parser).handle(execute(request, new ResultHandler()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an HTTP GET request to the RunDeck instance, on the given path. We will login first, and then execute the
|
||||
* API call. At the end, the given parser will be used to convert the response to a more useful result object.
|
||||
*
|
||||
* @param apiPath on which we will make the HTTP request - see {@link ApiPathBuilder}
|
||||
* @param parser used to parse the response
|
||||
*
|
||||
* @return the result of the call, as formatted by the parser
|
||||
*
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
*/
|
||||
public int get(ApiPathBuilder apiPath, OutputStream outputStream) throws RundeckApiException,
|
||||
RundeckApiLoginException, RundeckApiTokenException, IOException {
|
||||
HttpGet request = new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath);
|
||||
if (null != apiPath.getAccept()) {
|
||||
request.setHeader("Accept", apiPath.getAccept());
|
||||
}
|
||||
final WriteOutHandler writeOutHandler = new WriteOutHandler(outputStream);
|
||||
Handler<HttpResponse,Integer> handler = writeOutHandler;
|
||||
if(null!=apiPath.getRequiredContentType()){
|
||||
handler = new RequireContentTypeHandler<Integer>(apiPath.getRequiredContentType(), handler);
|
||||
}
|
||||
final int wrote = execute(request, handler);
|
||||
if(writeOutHandler.thrown!=null){
|
||||
throw writeOutHandler.thrown;
|
||||
}
|
||||
return wrote;
|
||||
}
|
||||
/**
|
||||
* Execute an HTTP request to the RunDeck instance. We will login first, and then execute the API call.
|
||||
*
|
||||
*
|
||||
* @param request to execute. see {@link HttpGet}, {@link HttpDelete}, and so on...
|
||||
* @return a new {@link InputStream} instance, not linked with network resources
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
*/
|
||||
private ByteArrayInputStream execute(HttpRequestBase request) throws RundeckApiException, RundeckApiLoginException,
|
||||
private ByteArrayInputStream execute(HttpUriRequest request) throws RundeckApiException, RundeckApiLoginException,
|
||||
RundeckApiTokenException {
|
||||
return execute(request, new ResultHandler() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles one type into another
|
||||
* @param <T>
|
||||
* @param <V>
|
||||
*/
|
||||
private static interface Handler<T,V>{
|
||||
public V handle(T response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles parsing inputstream via a parser
|
||||
* @param <S>
|
||||
*/
|
||||
private static class ParserHandler<S> implements Handler<InputStream,S> {
|
||||
XmlNodeParser<S> parser;
|
||||
|
||||
private ParserHandler(XmlNodeParser<S> parser) {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public S handle(InputStream response) {
|
||||
// read and parse the response
|
||||
return parser.parseXmlNode(ParserHelper.loadDocument(response));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles writing response to an output stream
|
||||
*/
|
||||
private static class ChainHandler<T> implements Handler<HttpResponse,T> {
|
||||
Handler<HttpResponse, T> chain;
|
||||
private ChainHandler(Handler<HttpResponse,T> chain) {
|
||||
this.chain=chain;
|
||||
}
|
||||
@Override
|
||||
public T handle(final HttpResponse response) {
|
||||
return chain.handle(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles writing response to an output stream
|
||||
*/
|
||||
private static class RequireContentTypeHandler<T> extends ChainHandler<T> {
|
||||
String contentType;
|
||||
|
||||
private RequireContentTypeHandler(final String contentType, final Handler<HttpResponse, T> chain) {
|
||||
super(chain);
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T handle(final HttpResponse response) {
|
||||
final Header firstHeader = response.getFirstHeader("Content-Type");
|
||||
final String[] split = firstHeader.getValue().split(";");
|
||||
boolean matched=false;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
if (this.contentType.equalsIgnoreCase(s.trim())) {
|
||||
matched=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!matched) {
|
||||
throw new RundeckApiException.RundeckApiHttpContentTypeException(firstHeader.getValue(),
|
||||
this.contentType);
|
||||
}
|
||||
return super.handle(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles writing response to an output stream
|
||||
*/
|
||||
private static class WriteOutHandler implements Handler<HttpResponse,Integer> {
|
||||
private WriteOutHandler(OutputStream writeOut) {
|
||||
this.writeOut = writeOut;
|
||||
}
|
||||
|
||||
OutputStream writeOut;
|
||||
IOException thrown;
|
||||
@Override
|
||||
public Integer handle(final HttpResponse response) {
|
||||
try {
|
||||
return IOUtils.copy(response.getEntity().getContent(), writeOut);
|
||||
} catch (IOException e) {
|
||||
thrown=e;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reading response into a byte array stream
|
||||
*/
|
||||
private static class ResultHandler implements Handler<HttpResponse,ByteArrayInputStream> {
|
||||
@Override
|
||||
public ByteArrayInputStream handle(final HttpResponse response) {
|
||||
// return a new inputStream, so that we can close all network resources
|
||||
try {
|
||||
return new ByteArrayInputStream(EntityUtils.toByteArray(response.getEntity()));
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiException("Failed to consume entity and convert the inputStream", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Execute an HTTP request to the RunDeck instance. We will login first, and then execute the API call.
|
||||
*
|
||||
* @param request to execute. see {@link HttpGet}, {@link HttpDelete}, and so on...
|
||||
* @return a new {@link InputStream} instance, not linked with network resources
|
||||
* @throws RundeckApiException in case of error when calling the API
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
*/
|
||||
private <T> T execute(HttpUriRequest request, Handler<HttpResponse,T> handler) throws RundeckApiException,
|
||||
RundeckApiLoginException,
|
||||
RundeckApiTokenException {
|
||||
HttpClient httpClient = instantiateHttpClient();
|
||||
try {
|
||||
|
@ -345,7 +549,8 @@ class ApiCall {
|
|||
|
||||
// in case of error, we get a redirect to /api/error
|
||||
// that we need to follow manually for POST and DELETE requests (as GET)
|
||||
if (response.getStatusLine().getStatusCode() / 100 == 3) {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
if (statusCode / 100 == 3) {
|
||||
String newLocation = response.getFirstHeader("Location").getValue();
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
|
@ -355,33 +560,31 @@ class ApiCall {
|
|||
request = new HttpGet(newLocation);
|
||||
try {
|
||||
response = httpClient.execute(request);
|
||||
statusCode = response.getStatusLine().getStatusCode();
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiException("Failed to execute an HTTP GET on url : " + request.getURI(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// check the response code (should be 2xx, even in case of error : error message is in the XML result)
|
||||
if (response.getStatusLine().getStatusCode() / 100 != 2) {
|
||||
if (response.getStatusLine().getStatusCode() == 403 &&
|
||||
if (statusCode / 100 != 2) {
|
||||
if (statusCode == 403 &&
|
||||
(client.getToken() != null || client.getSessionID() != null)) {
|
||||
throw new RundeckApiTokenException("Invalid Token or sessionID ! Got HTTP response '" + response.getStatusLine()
|
||||
+ "' for " + request.getURI());
|
||||
} else {
|
||||
throw new RundeckApiException("Invalid HTTP response '" + response.getStatusLine() + "' for "
|
||||
+ request.getURI());
|
||||
throw new RundeckApiException.RundeckApiHttpStatusException("Invalid HTTP response '" + response.getStatusLine() + "' for "
|
||||
+ request.getURI(), statusCode);
|
||||
}
|
||||
}
|
||||
if(statusCode==204){
|
||||
return null;
|
||||
}
|
||||
if (response.getEntity() == null) {
|
||||
throw new RundeckApiException("Empty RunDeck response ! HTTP status line is : "
|
||||
+ response.getStatusLine());
|
||||
}
|
||||
|
||||
// return a new inputStream, so that we can close all network resources
|
||||
try {
|
||||
return new ByteArrayInputStream(EntityUtils.toByteArray(response.getEntity()));
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiException("Failed to consume entity and convert the inputStream", e);
|
||||
}
|
||||
return handler.handle(response);
|
||||
} finally {
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
}
|
||||
|
@ -390,79 +593,102 @@ class ApiCall {
|
|||
/**
|
||||
* Do the actual work of login, using the given {@link HttpClient} instance. You'll need to re-use this instance
|
||||
* when making API calls (such as running a job). Only use this in case of login-based authentication.
|
||||
*
|
||||
*
|
||||
* @param httpClient pre-instantiated
|
||||
* @throws RundeckApiLoginException if the login failed
|
||||
*/
|
||||
private String login(HttpClient httpClient) throws RundeckApiLoginException {
|
||||
String location = client.getUrl() + "/j_security_check";
|
||||
String sessionID = null;
|
||||
while (true) {
|
||||
HttpPost postLogin = new HttpPost(location);
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new BasicNameValuePair("j_username", client.getLogin()));
|
||||
params.add(new BasicNameValuePair("j_password", client.getPassword()));
|
||||
params.add(new BasicNameValuePair("action", "login"));
|
||||
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
postLogin.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
|
||||
response = httpClient.execute(postLogin);
|
||||
Header cookieHeader = response.getFirstHeader("Set-Cookie");
|
||||
if(cookieHeader != null){
|
||||
String cookieStr = cookieHeader.getValue();
|
||||
if(cookieStr != null){
|
||||
int i1 = cookieStr.indexOf("JSESSIONID=");
|
||||
if(i1 >= 0){
|
||||
cookieStr = cookieStr.substring(i1 + "JSESSIONID=".length());
|
||||
int i2 = cookieStr.indexOf(";");
|
||||
if(i2 >= 0){
|
||||
sessionID = cookieStr.substring(0, i2);
|
||||
}
|
||||
// 1. call expected GET request
|
||||
String location = client.getUrl();
|
||||
|
||||
try {
|
||||
HttpGet getRequest = new HttpGet(location);
|
||||
HttpResponse response = httpClient.execute(getRequest);
|
||||
|
||||
// sessionID stored in case user wants to cache it for reuse
|
||||
Header cookieHeader = response.getFirstHeader("Set-Cookie");
|
||||
if (cookieHeader != null) {
|
||||
String cookieStr = cookieHeader.getValue();
|
||||
if (cookieStr != null) {
|
||||
int i1 = cookieStr.indexOf("JSESSIONID=");
|
||||
if (i1 >= 0) {
|
||||
cookieStr = cookieStr.substring(i1 + "JSESSIONID=".length());
|
||||
int i2 = cookieStr.indexOf(";");
|
||||
if (i2 >= 0) {
|
||||
sessionID = cookieStr.substring(0, i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to consume entity (release connection)", e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to get request on " + location, e);
|
||||
}
|
||||
|
||||
// 2. then call POST login request
|
||||
location += "/j_security_check";
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
HttpPost postLogin = new HttpPost(location);
|
||||
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
|
||||
params.add(new BasicNameValuePair("j_username", client.getLogin()));
|
||||
params.add(new BasicNameValuePair("j_password", client.getPassword()));
|
||||
params.add(new BasicNameValuePair("action", "login"));
|
||||
postLogin.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
|
||||
HttpResponse response = httpClient.execute(postLogin);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() / 100 == 3) {
|
||||
// HTTP client refuses to handle redirects (code 3xx) for POST, so we have to do it manually...
|
||||
location = response.getFirstHeader("Location").getValue();
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to consume entity (release connection)", e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() / 100 != 2) {
|
||||
throw new RundeckApiLoginException("Invalid HTTP response '" + response.getStatusLine() + "' for "
|
||||
+ location);
|
||||
}
|
||||
|
||||
try {
|
||||
String content = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
|
||||
if (StringUtils.contains(content, "j_security_check")) {
|
||||
throw new RundeckApiLoginException("Login failed for user " + client.getLogin());
|
||||
}
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to consume entity (release connection)", e);
|
||||
}
|
||||
break;
|
||||
} catch (IOException io) {
|
||||
throw new RundeckApiLoginException("Failed to read RunDeck result", io);
|
||||
} catch (ParseException p) {
|
||||
throw new RundeckApiLoginException("Failed to parse RunDeck response", p);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to post login form on " + location, e);
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() / 100 == 3) {
|
||||
// HTTP client refuses to handle redirects (code 3xx) for POST, so we have to do it manually...
|
||||
location = response.getFirstHeader("Location").getValue();
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to consume entity (release connection)", e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (response.getStatusLine().getStatusCode() / 100 != 2) {
|
||||
throw new RundeckApiLoginException("Invalid HTTP response '" + response.getStatusLine() + "' for "
|
||||
+ location);
|
||||
}
|
||||
try {
|
||||
String content = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
|
||||
if (StringUtils.contains(content, "j_security_check")) {
|
||||
throw new RundeckApiLoginException("Login failed for user " + client.getLogin());
|
||||
}
|
||||
try {
|
||||
EntityUtils.consume(response.getEntity());
|
||||
} catch (IOException e) {
|
||||
throw new RundeckApiLoginException("Failed to consume entity (release connection)", e);
|
||||
}
|
||||
} catch (IOException io) {
|
||||
throw new RundeckApiLoginException("Failed to read RunDeck result", io);
|
||||
} catch (ParseException p) {
|
||||
throw new RundeckApiLoginException("Failed to parse RunDeck response", p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return sessionID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiate a new {@link HttpClient} instance, configured to accept all SSL certificates
|
||||
*
|
||||
*
|
||||
* @return an {@link HttpClient} instance - won't be null
|
||||
*/
|
||||
private HttpClient instantiateHttpClient() {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.rundeck.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -26,6 +27,8 @@ import java.util.Properties;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.dom4j.Document;
|
||||
import org.rundeck.api.generator.XmlDocumentGenerator;
|
||||
import org.rundeck.api.util.ParametersUtil;
|
||||
|
||||
/**
|
||||
|
@ -38,9 +41,17 @@ class ApiPathBuilder {
|
|||
/** Internally, we store everything in a {@link StringBuilder} */
|
||||
private final StringBuilder apiPath;
|
||||
|
||||
private String accept="text/xml";
|
||||
|
||||
/** When POSTing, we can add attachments */
|
||||
private final Map<String, InputStream> attachments;
|
||||
private final List<NameValuePair> form = new ArrayList<NameValuePair>();
|
||||
private Document xmlDocument;
|
||||
private InputStream contentStream;
|
||||
private File contentFile;
|
||||
private String contentType;
|
||||
private String requiredContentType;
|
||||
private boolean emptyContent = false;
|
||||
|
||||
/** Marker for using the right separator between parameters ("?" or "&") */
|
||||
private boolean firstParamDone = false;
|
||||
|
@ -54,6 +65,10 @@ class ApiPathBuilder {
|
|||
public ApiPathBuilder(String... paths) {
|
||||
apiPath = new StringBuilder();
|
||||
attachments = new HashMap<String, InputStream>();
|
||||
paths(paths);
|
||||
}
|
||||
|
||||
public ApiPathBuilder paths(String... paths) {
|
||||
if (paths != null) {
|
||||
for (String path : paths) {
|
||||
if (StringUtils.isNotBlank(path)) {
|
||||
|
@ -61,8 +76,16 @@ class ApiPathBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the accept header
|
||||
*/
|
||||
public ApiPathBuilder accept(String mimeTypes) {
|
||||
accept=mimeTypes;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Visit a {@link BuildsParameters} and add the parameters
|
||||
*/
|
||||
|
@ -257,6 +280,69 @@ class ApiPathBuilder {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When POSTing a request, use the given {@link InputStream} as the content of the request. This
|
||||
* will only add the stream if it is not null.
|
||||
*
|
||||
* @param contentType MIME content type ofr hte request
|
||||
* @param stream content stream
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public ApiPathBuilder content(final String contentType, final InputStream stream) {
|
||||
if (stream != null && contentType != null) {
|
||||
this.contentStream=stream;
|
||||
this.contentType=contentType;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When POSTing a request, use the given {@link File} as the content of the request. This
|
||||
* will only add the stream if it is not null.
|
||||
*
|
||||
* @param contentType MIME content type ofr hte request
|
||||
* @param file content from a file
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public ApiPathBuilder content(final String contentType, final File file) {
|
||||
if (file != null && contentType != null) {
|
||||
this.contentFile=file;
|
||||
this.contentType=contentType;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When POSTing a request, send an empty request.
|
||||
*
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public ApiPathBuilder emptyContent() {
|
||||
this.emptyContent=true;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When POSTing a request, add the given XMl Document as the content of the request.
|
||||
*
|
||||
* @param document XMl document to send
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public ApiPathBuilder xml(final Document document) {
|
||||
if (document != null) {
|
||||
xmlDocument = document;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When POSTing a request, add the given XMl Document as the content of the request.
|
||||
*
|
||||
* @param document XMl document to send
|
||||
* @return this, for method chaining
|
||||
*/
|
||||
public ApiPathBuilder xml(final XmlDocumentGenerator document) {
|
||||
if (document != null) {
|
||||
xmlDocument = document.generateXmlDocument();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return all attachments to be POSTed, with their names
|
||||
|
@ -302,7 +388,43 @@ class ApiPathBuilder {
|
|||
* Return true if there are any Attachments or Form data for a POST request.
|
||||
*/
|
||||
public boolean hasPostContent() {
|
||||
return getAttachments().size() > 0 || getForm().size() > 0;
|
||||
return getAttachments().size() > 0 || getForm().size() > 0 || null != xmlDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept header value, default "text/xml"
|
||||
*/
|
||||
public String getAccept() {
|
||||
return accept;
|
||||
}
|
||||
|
||||
public Document getXmlDocument() {
|
||||
return xmlDocument;
|
||||
}
|
||||
|
||||
public InputStream getContentStream() {
|
||||
return contentStream;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public File getContentFile() {
|
||||
return contentFile;
|
||||
}
|
||||
|
||||
public boolean isEmptyContent() {
|
||||
return emptyContent;
|
||||
}
|
||||
|
||||
public ApiPathBuilder requireContentType(String contentType) {
|
||||
this.requiredContentType=contentType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRequiredContentType() {
|
||||
return requiredContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,6 +36,9 @@ import java.util.*;
|
|||
abstract class QueryParameterBuilder implements ApiPathBuilder.BuildsParameters {
|
||||
public static final String W3C_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||
static final SimpleDateFormat format = new SimpleDateFormat(W3C_DATE_FORMAT);
|
||||
static {
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value to the builder for a given key
|
||||
|
|
|
@ -82,5 +82,65 @@ public class RundeckApiException extends RuntimeException {
|
|||
super(message, cause);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Error due to unexpected HTTP status
|
||||
*/
|
||||
public static class RundeckApiHttpStatusException extends RundeckApiAuthException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int statusCode;
|
||||
|
||||
public RundeckApiHttpStatusException(String message, int statusCode) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public RundeckApiHttpStatusException(String message, Throwable cause, int statusCode) {
|
||||
super(message, cause);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error due to unexpected HTTP content-type
|
||||
*/
|
||||
public static class RundeckApiHttpContentTypeException extends RundeckApiAuthException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String contentType;
|
||||
private String requiredContentType;
|
||||
|
||||
public RundeckApiHttpContentTypeException(final String contentType,
|
||||
final String requiredContentType) {
|
||||
super("Unexpected content-type: '" + contentType + "', expected: '" + requiredContentType + "'");
|
||||
this.contentType = contentType;
|
||||
this.requiredContentType = requiredContentType;
|
||||
}
|
||||
public RundeckApiHttpContentTypeException(final String message, final String contentType,
|
||||
final String requiredContentType) {
|
||||
super(message);
|
||||
this.contentType = contentType;
|
||||
this.requiredContentType = requiredContentType;
|
||||
}
|
||||
|
||||
public RundeckApiHttpContentTypeException(final String message, final Throwable cause, final String contentType,
|
||||
final String requiredContentType) {
|
||||
super(message, cause);
|
||||
this.contentType = contentType;
|
||||
this.requiredContentType = requiredContentType;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public String getRequiredContentType() {
|
||||
return requiredContentType;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
38
src/main/java/org/rundeck/api/domain/ArchiveImport.java
Normal file
38
src/main/java/org/rundeck/api/domain/ArchiveImport.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ArchiveImport describes the result of an {@link org.rundeck.api.RundeckClient#importArchive(String, java.io.File,
|
||||
* boolean, boolean)} request.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-09
|
||||
*/
|
||||
public class ArchiveImport {
|
||||
private boolean successful;
|
||||
private List<String> errorMessages;
|
||||
|
||||
public ArchiveImport(final boolean successful, final List<String> errorMessages) {
|
||||
this.successful = successful;
|
||||
this.errorMessages = errorMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if successful
|
||||
* @return
|
||||
*/
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of error messages if unsuccessful
|
||||
* @return
|
||||
*/
|
||||
public List<String> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
|
||||
}
|
58
src/main/java/org/rundeck/api/domain/BaseKeyResource.java
Normal file
58
src/main/java/org/rundeck/api/domain/BaseKeyResource.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BaseKeyResource is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class BaseKeyResource extends BaseStorageResource implements KeyResource {
|
||||
private boolean privateKey;
|
||||
|
||||
public BaseKeyResource() {
|
||||
}
|
||||
|
||||
|
||||
public boolean isPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(boolean privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
ArrayList<KeyResource> keyResources = new ArrayList<KeyResource>();
|
||||
|
||||
@Override
|
||||
public void setDirectoryContents(List<? extends StorageResource> directoryContents) {
|
||||
for (StorageResource directoryContent : directoryContents) {
|
||||
keyResources.add(from(directoryContent));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyResource> getDirectoryContents() {
|
||||
return keyResources;
|
||||
}
|
||||
|
||||
public static BaseKeyResource from(final StorageResource source) {
|
||||
final BaseKeyResource baseSshKeyResource = new BaseKeyResource();
|
||||
baseSshKeyResource.setDirectory(source.isDirectory());
|
||||
baseSshKeyResource.setPath(source.getPath());
|
||||
baseSshKeyResource.setName(source.getName());
|
||||
baseSshKeyResource.setMetadata(source.getMetadata());
|
||||
baseSshKeyResource.setUrl(source.getUrl());
|
||||
if (!baseSshKeyResource.isDirectory()) {
|
||||
baseSshKeyResource.setPrivateKey(
|
||||
null != baseSshKeyResource.getMetadata() && "private".equals(baseSshKeyResource.getMetadata().get
|
||||
("Rundeck-key-type"))
|
||||
);
|
||||
} else if (null != source.getDirectoryContents()) {
|
||||
baseSshKeyResource.setDirectoryContents(source.getDirectoryContents());
|
||||
}
|
||||
return baseSshKeyResource;
|
||||
}
|
||||
}
|
63
src/main/java/org/rundeck/api/domain/BaseState.java
Normal file
63
src/main/java/org/rundeck/api/domain/BaseState.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Base execution status for a step
|
||||
*/
|
||||
public class BaseState {
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private Date updateTime;
|
||||
private RundeckWFExecState executionState;
|
||||
|
||||
/**
|
||||
* Time that the execution of this step started
|
||||
* @return
|
||||
*/
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time that the execution of this step finished, or null if it has not completed
|
||||
* @return
|
||||
*/
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current state of the execution
|
||||
* @return
|
||||
*/
|
||||
public RundeckWFExecState getExecutionState() {
|
||||
return executionState;
|
||||
}
|
||||
|
||||
public void setExecutionState(RundeckWFExecState executionState) {
|
||||
this.executionState = executionState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time that this state was last updated
|
||||
* @return
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* BaseStorageResource is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class BaseStorageResource implements StorageResource {
|
||||
private String path;
|
||||
private String url;
|
||||
private String name;
|
||||
private Map<String,String> metadata;
|
||||
private boolean directory;
|
||||
private List<? extends StorageResource> directoryContents;
|
||||
|
||||
public BaseStorageResource() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory() {
|
||||
return directory;
|
||||
}
|
||||
|
||||
public void setDirectory(boolean directory) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends StorageResource> getDirectoryContents() {
|
||||
return directoryContents;
|
||||
}
|
||||
|
||||
public void setDirectoryContents(List<? extends StorageResource> directoryContents) {
|
||||
this.directoryContents = directoryContents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseStorageResource{" +
|
||||
"path='" + path + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", directory=" + directory +
|
||||
'}';
|
||||
}
|
||||
}
|
68
src/main/java/org/rundeck/api/domain/ConfigProperty.java
Normal file
68
src/main/java/org/rundeck/api/domain/ConfigProperty.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ConfigProperty is a single configuration property key and value.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-07
|
||||
*/
|
||||
public class ConfigProperty implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public ConfigProperty() {
|
||||
}
|
||||
|
||||
public ConfigProperty(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ConfigProperty)) return false;
|
||||
|
||||
ConfigProperty that = (ConfigProperty) o;
|
||||
|
||||
if (!key.equals(that.key)) return false;
|
||||
if (!value.equals(that.value)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = key.hashCode();
|
||||
result = 31 * result + value.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigProperty{" +
|
||||
"key='" + key + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DeleteExecutionsResponse is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-06
|
||||
*/
|
||||
public class DeleteExecutionsResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int failedCount;
|
||||
private int successCount;
|
||||
private boolean allsuccessful;
|
||||
private int requestCount;
|
||||
private List<DeleteFailure> failures;
|
||||
|
||||
public int getFailedCount() {
|
||||
return failedCount;
|
||||
}
|
||||
|
||||
public void setFailedCount(final int failedCount) {
|
||||
this.failedCount = failedCount;
|
||||
}
|
||||
|
||||
public int getSuccessCount() {
|
||||
return successCount;
|
||||
}
|
||||
|
||||
public void setSuccessCount(final int successCount) {
|
||||
this.successCount = successCount;
|
||||
}
|
||||
|
||||
public boolean isAllsuccessful() {
|
||||
return allsuccessful;
|
||||
}
|
||||
|
||||
public void setAllsuccessful(final boolean allsuccessful) {
|
||||
this.allsuccessful = allsuccessful;
|
||||
}
|
||||
|
||||
public int getRequestCount() {
|
||||
return requestCount;
|
||||
}
|
||||
|
||||
public void setRequestCount(final int requestCount) {
|
||||
this.requestCount = requestCount;
|
||||
}
|
||||
|
||||
public List<DeleteFailure> getFailures() {
|
||||
return failures;
|
||||
}
|
||||
|
||||
public void setFailures(final List<DeleteFailure> failures) {
|
||||
this.failures = failures;
|
||||
}
|
||||
|
||||
public static class DeleteFailure implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long executionId;
|
||||
private String message;
|
||||
|
||||
public Long getExecutionId() {
|
||||
return executionId;
|
||||
}
|
||||
|
||||
public void setExecutionId(final Long executionId) {
|
||||
this.executionId = executionId;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
23
src/main/java/org/rundeck/api/domain/KeyResource.java
Normal file
23
src/main/java/org/rundeck/api/domain/KeyResource.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* KeyResource represents a directory or an SSH key file
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public interface KeyResource extends StorageResource {
|
||||
/**
|
||||
* Return true if this is a file and is a private SSH key file.
|
||||
* @return
|
||||
*/
|
||||
public boolean isPrivateKey();
|
||||
|
||||
/**
|
||||
* Return the list of SSH Key resources if this is a directory
|
||||
* @return
|
||||
*/
|
||||
public List<KeyResource> getDirectoryContents();
|
||||
}
|
64
src/main/java/org/rundeck/api/domain/ProjectConfig.java
Normal file
64
src/main/java/org/rundeck/api/domain/ProjectConfig.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ProjectConfig is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private LinkedHashMap<String, String> properties = new LinkedHashMap<String, String>();
|
||||
|
||||
public ProjectConfig() {
|
||||
}
|
||||
|
||||
public ProjectConfig(Map<String, String> properties) {
|
||||
setProperties(properties);
|
||||
}
|
||||
|
||||
public void setProperty(final String key, final String value) {
|
||||
getProperties().put(key, value);
|
||||
}
|
||||
|
||||
public void addProperties(final Map<String, String> values) {
|
||||
getProperties().putAll(values);
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(final Map<String, String> properties) {
|
||||
this.properties = new LinkedHashMap<String, String>(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ProjectConfig)) return false;
|
||||
|
||||
ProjectConfig that = (ProjectConfig) o;
|
||||
|
||||
if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return properties != null ? properties.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectConfig{" +
|
||||
"properties=" + properties +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ package org.rundeck.api.domain;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||
|
||||
|
@ -52,6 +53,8 @@ public class RundeckExecution implements Serializable {
|
|||
private String description;
|
||||
private String argstring;
|
||||
private String project;
|
||||
private Set<RundeckNodeIdentity> successfulNodes;
|
||||
private Set<RundeckNodeIdentity> failedNodes;
|
||||
|
||||
/**
|
||||
* @return the duration of the execution in milliseconds (or null if the duration is still running, or has been
|
||||
|
@ -174,7 +177,10 @@ public class RundeckExecution implements Serializable {
|
|||
return "RundeckExecution [id=" + id + ", description=" + description + ", url=" + url + ", status=" + status
|
||||
+ ", argstring=" + argstring
|
||||
+ ", startedBy=" + startedBy + ", startedAt=" + startedAt + ", endedAt=" + endedAt
|
||||
+ ", durationInSeconds=" + getDurationInSeconds() + ", abortedBy=" + abortedBy + ", job=" + job + "]";
|
||||
+ ", durationInSeconds=" + getDurationInSeconds() + ", abortedBy=" + abortedBy + ", job=" + job
|
||||
+ ", successfulNodes=" + getSuccessfulNodes()
|
||||
+ ", failedNodes=" + getFailedNodes()
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -281,6 +287,22 @@ public class RundeckExecution implements Serializable {
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
public Set<RundeckNodeIdentity> getSuccessfulNodes() {
|
||||
return successfulNodes;
|
||||
}
|
||||
|
||||
public void setSuccessfulNodes(Set<RundeckNodeIdentity> successfulNodes) {
|
||||
this.successfulNodes = successfulNodes;
|
||||
}
|
||||
|
||||
public Set<RundeckNodeIdentity> getFailedNodes() {
|
||||
return failedNodes;
|
||||
}
|
||||
|
||||
public void setFailedNodes(Set<RundeckNodeIdentity> failedNodes) {
|
||||
this.failedNodes = failedNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of an execution
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The state of an Execution
|
||||
*/
|
||||
public class RundeckExecutionState extends WorkflowState{
|
||||
private long executionId;
|
||||
private Set<RundeckNodeIdentity> allNodes;
|
||||
private Map<String, List<WorkflowStepContextState>> nodeStates;
|
||||
|
||||
/**
|
||||
* Return the set of all rundeck nodes targeted in this execution
|
||||
* @return
|
||||
*/
|
||||
public Set<RundeckNodeIdentity> getAllNodes() {
|
||||
return allNodes;
|
||||
}
|
||||
|
||||
public void setAllNodes(Set<RundeckNodeIdentity> allNodes) {
|
||||
this.allNodes = allNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the map of node name to step state list
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<WorkflowStepContextState>> getNodeStates() {
|
||||
return nodeStates;
|
||||
}
|
||||
|
||||
public void setNodeStates(Map<String, List<WorkflowStepContextState>> nodeStates) {
|
||||
this.nodeStates = nodeStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this execution's ID
|
||||
* @return
|
||||
*/
|
||||
public long getExecutionId() {
|
||||
return executionId;
|
||||
}
|
||||
|
||||
public void setExecutionId(long executionId) {
|
||||
this.executionId = executionId;
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
*
|
||||
* @author Vincent Behar
|
||||
*/
|
||||
public class RundeckNode implements Serializable {
|
||||
public class RundeckNode implements Serializable, RundeckNodeIdentity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -63,6 +63,7 @@ public class RundeckNode implements Serializable {
|
|||
/** URL to an external resource model service. (optional) */
|
||||
private String remoteUrl;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
|
||||
/**
|
||||
* Identifies a node by name
|
||||
*/
|
||||
public interface RundeckNodeIdentity {
|
||||
/**
|
||||
* Return the rundeck Node name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
}
|
|
@ -22,9 +22,9 @@ public class RundeckOutput implements Serializable {
|
|||
|
||||
//private String error = null;
|
||||
|
||||
private Boolean unmodified;
|
||||
private Boolean unmodified = false;
|
||||
|
||||
private Boolean empty;
|
||||
private Boolean empty = false;
|
||||
|
||||
private int offset;
|
||||
|
||||
|
@ -46,6 +46,9 @@ public class RundeckOutput implements Serializable {
|
|||
|
||||
List<RundeckOutputEntry> logEntries = null;
|
||||
|
||||
private String filterNode;
|
||||
private String filterStep;
|
||||
|
||||
public Long getExecutionId() {
|
||||
return executionId;
|
||||
}
|
||||
|
@ -181,6 +184,7 @@ public class RundeckOutput implements Serializable {
|
|||
", execCompleted=" + execCompleted + ", hasFailedNodes=" + hasFailedNodes +
|
||||
", status=" + status + ", lastModified=" + lastModified +
|
||||
", execDuration=" + execDuration + ", percentLoaded=" + percentLoaded +
|
||||
", filterNode=" + filterNode + ", filterStep=" + filterStep +
|
||||
", totalSize=" + totalSize + "]";
|
||||
}
|
||||
|
||||
|
@ -203,6 +207,8 @@ public class RundeckOutput implements Serializable {
|
|||
result = prime * result + ((percentLoaded == null) ? 0 : percentLoaded.hashCode());
|
||||
result = prime * result + totalSize;
|
||||
result = prime * result + ((logEntries == null) ? 0 : logEntries.hashCode());
|
||||
result = prime * result + ((filterNode == null) ? 0 : filterNode.hashCode());
|
||||
result = prime * result + ((filterStep == null) ? 0 : filterStep.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -286,7 +292,40 @@ public class RundeckOutput implements Serializable {
|
|||
return false;
|
||||
} else if (!logEntries.equals(other.logEntries))
|
||||
return false;
|
||||
if (filterNode == null) {
|
||||
if (other.filterNode != null)
|
||||
return false;
|
||||
} else if (!filterNode.equals(other.filterNode))
|
||||
return false;
|
||||
if (filterStep == null) {
|
||||
if (other.filterStep != null)
|
||||
return false;
|
||||
} else if (!filterStep.equals(other.filterStep))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getFilterNode() {
|
||||
return filterNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the node name used to filter this output
|
||||
* @param filterNode
|
||||
*/
|
||||
public void setFilterNode(String filterNode) {
|
||||
this.filterNode = filterNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the step context used to filter this output
|
||||
* @return
|
||||
*/
|
||||
public String getFilterStep() {
|
||||
return filterStep;
|
||||
}
|
||||
|
||||
public void setFilterStep(String filterStep) {
|
||||
this.filterStep = filterStep;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a RunDeck output entry
|
||||
|
@ -11,7 +13,8 @@ public class RundeckOutputEntry implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String time = null;
|
||||
|
||||
private Date absoluteTime = null;
|
||||
|
||||
private RundeckLogLevel level = null;
|
||||
|
||||
private String message = null;
|
||||
|
@ -21,7 +24,9 @@ public class RundeckOutputEntry implements Serializable {
|
|||
private String command = null;
|
||||
|
||||
private String node = null;
|
||||
private String type = null;
|
||||
|
||||
private Map<String,String> metadata;
|
||||
|
||||
|
||||
public String getTime() {
|
||||
|
@ -77,8 +82,11 @@ public class RundeckOutputEntry implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "RundeckOutputEntry [time=" + time + ", level=" + level +
|
||||
", message=" + message + ", user=" + user + ", command=" +
|
||||
command + ", node=" + node + "]";
|
||||
", message=" + message + ", user=" + user
|
||||
+ ", command=" + command
|
||||
+ ", type=" + type
|
||||
+ ", metadata=" + metadata
|
||||
+ ", node=" + node + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,6 +99,8 @@ public class RundeckOutputEntry implements Serializable {
|
|||
result = prime * result + ((user == null) ? 0 : user.hashCode());
|
||||
result = prime * result + ((command == null) ? 0 : command.hashCode());
|
||||
result = prime * result + ((node == null) ? 0 : node.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -134,13 +144,49 @@ public class RundeckOutputEntry implements Serializable {
|
|||
return false;
|
||||
} else if (!node.equals(other.node))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
if (metadata == null) {
|
||||
if (other.metadata != null)
|
||||
return false;
|
||||
} else if (!metadata.equals(other.metadata))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* type of entry
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Map<String, String> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Date getAbsoluteTime() {
|
||||
return absoluteTime;
|
||||
}
|
||||
|
||||
public void setAbsoluteTime(Date absoluteTime) {
|
||||
this.absoluteTime = absoluteTime;
|
||||
}
|
||||
|
||||
|
||||
public static enum RundeckLogLevel {
|
||||
SEVERE, WARNING, INFO, CONFIG, FINEST;
|
||||
SEVERE, ERROR, WARNING, INFO, NORMAL, DEBUG, CONFIG, VERBOSE, FINEST,;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public class RundeckProject implements Serializable {
|
|||
|
||||
private String resourceModelProviderUrl;
|
||||
|
||||
private ProjectConfig projectConfig;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -56,10 +58,20 @@ public class RundeckProject implements Serializable {
|
|||
this.resourceModelProviderUrl = resourceModelProviderUrl;
|
||||
}
|
||||
|
||||
public ProjectConfig getProjectConfig() {
|
||||
return projectConfig;
|
||||
}
|
||||
|
||||
public void setProjectConfig(ProjectConfig projectConfig) {
|
||||
this.projectConfig = projectConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RundeckProject [name=" + name + ", description=" + description + ", resourceModelProviderUrl="
|
||||
+ resourceModelProviderUrl + "]";
|
||||
return "RundeckProject [name=" + name + ", description=" + description
|
||||
+ (null!=resourceModelProviderUrl? ", resourceModelProviderUrl=" + resourceModelProviderUrl : "")
|
||||
+ ", config="
|
||||
+ projectConfig + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,6 +81,7 @@ public class RundeckProject implements Serializable {
|
|||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((resourceModelProviderUrl == null) ? 0 : resourceModelProviderUrl.hashCode());
|
||||
result = prime * result + ((projectConfig == null) ? 0 : projectConfig.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -96,7 +109,11 @@ public class RundeckProject implements Serializable {
|
|||
return false;
|
||||
} else if (!resourceModelProviderUrl.equals(other.resourceModelProviderUrl))
|
||||
return false;
|
||||
if (projectConfig == null) {
|
||||
if (other.projectConfig != null)
|
||||
return false;
|
||||
} else if (!projectConfig.equals(other.projectConfig))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
36
src/main/java/org/rundeck/api/domain/RundeckToken.java
Normal file
36
src/main/java/org/rundeck/api/domain/RundeckToken.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
/**
|
||||
* RundeckToken is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class RundeckToken {
|
||||
private String user;
|
||||
private String token;
|
||||
|
||||
public RundeckToken() {
|
||||
}
|
||||
|
||||
public RundeckToken(String user, String token) {
|
||||
this.setUser(user);
|
||||
this.setToken(token);
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
43
src/main/java/org/rundeck/api/domain/RundeckWFExecState.java
Normal file
43
src/main/java/org/rundeck/api/domain/RundeckWFExecState.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
/**
|
||||
* An execution state for a workflow or node step
|
||||
*/
|
||||
public enum RundeckWFExecState {
|
||||
/**
|
||||
* Waiting to start running
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* Currently running
|
||||
*/
|
||||
RUNNING,
|
||||
/**
|
||||
* Running error handler
|
||||
*/
|
||||
RUNNING_HANDLER,
|
||||
/**
|
||||
* Finished running successfully
|
||||
*/
|
||||
SUCCEEDED,
|
||||
/**
|
||||
* Finished with a failure
|
||||
*/
|
||||
FAILED,
|
||||
/**
|
||||
* Execution was aborted
|
||||
*/
|
||||
ABORTED,
|
||||
/**
|
||||
* Partial success for some nodes
|
||||
*/
|
||||
NODE_PARTIAL_SUCCEEDED,
|
||||
/**
|
||||
* Mixed states among nodes
|
||||
*/
|
||||
NODE_MIXED,
|
||||
/**
|
||||
* After waiting the execution did not start
|
||||
*/
|
||||
NOT_STARTED,;
|
||||
}
|
54
src/main/java/org/rundeck/api/domain/StorageResource.java
Normal file
54
src/main/java/org/rundeck/api/domain/StorageResource.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StorageResource represents a directory or a file
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public interface StorageResource {
|
||||
/**
|
||||
* Return the storage path for this resource
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPath();
|
||||
|
||||
/**
|
||||
* Return the URL for this resource
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUrl();
|
||||
|
||||
/**
|
||||
* Return the file name if this is a file
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Return the metadata for this file if this is a file
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getMetadata();
|
||||
|
||||
/**
|
||||
* Return true if this is a directory, false if this is a file
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isDirectory();
|
||||
|
||||
/**
|
||||
* Return the list of directory contents if this is a directory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<? extends StorageResource> getDirectoryContents();
|
||||
}
|
52
src/main/java/org/rundeck/api/domain/WorkflowState.java
Normal file
52
src/main/java/org/rundeck/api/domain/WorkflowState.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents the state of a workflow of steps
|
||||
*/
|
||||
public class WorkflowState extends BaseState {
|
||||
private int stepCount;
|
||||
private Set<RundeckNodeIdentity> targetNodes;
|
||||
private List<WorkflowStepState> steps;
|
||||
|
||||
/**
|
||||
* Return the number of steps in this workflow
|
||||
* @return
|
||||
*/
|
||||
public int getStepCount() {
|
||||
return stepCount;
|
||||
}
|
||||
|
||||
public void setStepCount(int stepCount) {
|
||||
this.stepCount = stepCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify the target nodes of this workflow
|
||||
* @return
|
||||
*/
|
||||
public Set<RundeckNodeIdentity> getTargetNodes() {
|
||||
return targetNodes;
|
||||
}
|
||||
|
||||
public void setTargetNodes(Set<RundeckNodeIdentity> targetNodes) {
|
||||
this.targetNodes = targetNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of steps for this workflow
|
||||
* @return
|
||||
*/
|
||||
public List<WorkflowStepState> getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void setSteps(List<WorkflowStepState> steps) {
|
||||
this.steps = steps;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
/**
|
||||
* A state for a particular step
|
||||
*/
|
||||
public class WorkflowStepContextState extends BaseState {
|
||||
private String stepContextId;
|
||||
private int stepNum;
|
||||
|
||||
/**
|
||||
* The context id for the step in the form "#[/#[/#[...]]]" where "#" is a number
|
||||
* @return
|
||||
*/
|
||||
public String getStepContextId() {
|
||||
return stepContextId;
|
||||
}
|
||||
|
||||
public void setStepContextId(String stepContextId) {
|
||||
this.stepContextId = stepContextId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The step number of this step in the current workflow, 1 indexed.
|
||||
* @return
|
||||
*/
|
||||
public int getStepNum() {
|
||||
return stepNum;
|
||||
}
|
||||
|
||||
public void setStepNum(int stepNum) {
|
||||
this.stepNum = stepNum;
|
||||
}
|
||||
}
|
49
src/main/java/org/rundeck/api/domain/WorkflowStepState.java
Normal file
49
src/main/java/org/rundeck/api/domain/WorkflowStepState.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package org.rundeck.api.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the state of a step in a workflow
|
||||
*/
|
||||
public class WorkflowStepState extends WorkflowStepContextState {
|
||||
private boolean nodeStep;
|
||||
private WorkflowState subWorkflow;
|
||||
private Map<String, WorkflowStepContextState> nodeStates;
|
||||
|
||||
/**
|
||||
* Return true if this step runs on each target node
|
||||
* @return
|
||||
*/
|
||||
public boolean isNodeStep() {
|
||||
return nodeStep;
|
||||
}
|
||||
|
||||
public void setNodeStep(boolean nodeStep) {
|
||||
this.nodeStep = nodeStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return sub workflow if this step has one
|
||||
* @return
|
||||
*/
|
||||
public WorkflowState getSubWorkflow() {
|
||||
return subWorkflow;
|
||||
}
|
||||
|
||||
public void setSubWorkflow(WorkflowState subWorkflow) {
|
||||
this.subWorkflow = subWorkflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the state of each target node if this step runs on each target node
|
||||
* @return
|
||||
*/
|
||||
public Map<String, WorkflowStepContextState> getNodeStates() {
|
||||
return nodeStates;
|
||||
}
|
||||
|
||||
public void setNodeStates(Map<String, WorkflowStepContextState> nodeStates) {
|
||||
this.nodeStates = nodeStates;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentFactory;
|
||||
|
||||
/**
|
||||
* BaseDocGenerator generates a document using the element as the root.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public abstract class BaseDocGenerator implements XmlDocumentGenerator {
|
||||
@Override
|
||||
public Document generateXmlDocument() {
|
||||
return DocumentFactory.getInstance().createDocument(generateXmlElement());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.Element;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* DeleteExecutionsGenerator is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-06
|
||||
*/
|
||||
public class DeleteExecutionsGenerator extends BaseDocGenerator {
|
||||
private Set<Long> executionIds;
|
||||
|
||||
public DeleteExecutionsGenerator(final Set<Long> executionIds) {
|
||||
this.executionIds = executionIds;
|
||||
}
|
||||
|
||||
@Override public Element generateXmlElement() {
|
||||
Element rootElem = DocumentFactory.getInstance().createElement("executions");
|
||||
for (Long executionId : executionIds) {
|
||||
rootElem.addElement("execution").addAttribute("id", Long.toString(executionId));
|
||||
}
|
||||
return rootElem;
|
||||
}
|
||||
|
||||
public Set<Long> getExecutionIds() {
|
||||
return executionIds;
|
||||
}
|
||||
|
||||
public void setExecutionIds(final Set<Long> executionIds) {
|
||||
this.executionIds = executionIds;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.Element;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
|
||||
/**
|
||||
* ProjectConfigGenerator is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectConfigGenerator extends BaseDocGenerator {
|
||||
private ProjectConfig config;
|
||||
|
||||
public ProjectConfigGenerator(ProjectConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element generateXmlElement() {
|
||||
Element configEl = DocumentFactory.getInstance().createElement("config");
|
||||
if (null != config.getProperties()) {
|
||||
for (String s : config.getProperties().keySet()) {
|
||||
Element property = configEl.addElement("property");
|
||||
property.addAttribute("key", s);
|
||||
property.addAttribute("value", config.getProperties().get(s));
|
||||
}
|
||||
}
|
||||
return configEl;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.Element;
|
||||
import org.rundeck.api.domain.ConfigProperty;
|
||||
|
||||
/**
|
||||
* ProjectConfigPropertyGenerator generates a {@literal <property/>} element representing a configuration property.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-07
|
||||
*/
|
||||
public class ProjectConfigPropertyGenerator extends BaseDocGenerator {
|
||||
private ConfigProperty property;
|
||||
|
||||
public ProjectConfigPropertyGenerator(ConfigProperty property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element generateXmlElement() {
|
||||
Element propElem = DocumentFactory.getInstance().createElement("property");
|
||||
propElem.addAttribute("key", property.getKey());
|
||||
propElem.addAttribute("value", property.getValue());
|
||||
|
||||
return propElem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.Element;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
/**
|
||||
* ProjectGenerator is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectGenerator extends BaseDocGenerator {
|
||||
RundeckProject project;
|
||||
|
||||
public ProjectGenerator(RundeckProject project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element generateXmlElement() {
|
||||
Element rootElem = DocumentFactory.getInstance().createElement("project");
|
||||
rootElem.addElement("name").setText(project.getName());
|
||||
ProjectConfig configuration = project.getProjectConfig();
|
||||
if (null != configuration) {
|
||||
rootElem.add(new ProjectConfigGenerator(configuration).generateXmlElement());
|
||||
}
|
||||
return rootElem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
|
||||
/**
|
||||
* XmlDocumentGenerator is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public interface XmlDocumentGenerator {
|
||||
|
||||
/**
|
||||
* Generate the XML {@link org.dom4j.Node}
|
||||
*
|
||||
* @return any object holding the converted value
|
||||
*/
|
||||
Element generateXmlElement();
|
||||
/**
|
||||
* Generate the XML {@link org.dom4j.Node}
|
||||
*
|
||||
* @param node
|
||||
*
|
||||
* @return any object holding the converted value
|
||||
*/
|
||||
Document generateXmlDocument();
|
||||
}
|
78
src/main/java/org/rundeck/api/parser/APIV11Helper.java
Normal file
78
src/main/java/org/rundeck/api/parser/APIV11Helper.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
|
||||
/**
|
||||
* Utility to handle API v11 responses with <result> wrapper element.
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-10
|
||||
*/
|
||||
public class APIV11Helper {
|
||||
|
||||
/**
|
||||
* Detect and remove extra <result> wrapper around xml response.
|
||||
* @param parser
|
||||
* @param xpath
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> XmlNodeParser<T> unwrapIfNeeded(
|
||||
final XmlNodeParser<T> parser,
|
||||
final String xpath
|
||||
) {
|
||||
return new NodeParser_unwrap<T>(parser, xpath);
|
||||
}
|
||||
|
||||
static class NodeParser_unwrap<T> implements XmlNodeParser<T> {
|
||||
XmlNodeParser<T> parser;
|
||||
String xpath;
|
||||
|
||||
public NodeParser_unwrap(final XmlNodeParser<T> parser, final String xpath) {
|
||||
this.parser = parser;
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override public T parseXmlNode(final Node node) {
|
||||
|
||||
Node sourceNode = unwrapResultElement(node, xpath);
|
||||
return parser.parseXmlNode(sourceNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the node for matching the xpath string, if it doesnt match, attempt to prefix it with
|
||||
* "result" and match that. If that matches, return the first child of the 'result' element.
|
||||
*
|
||||
* @param node
|
||||
* @param xpath
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Node unwrapResultElement(final Node node, final String xpath) {
|
||||
Node sourceNode = node;
|
||||
final Node tested = sourceNode.selectSingleNode(xpath);
|
||||
if (null == tested && !xpath.startsWith("result")) {
|
||||
//prepend /result
|
||||
if (null != sourceNode.selectSingleNode("result" + xpath)) {
|
||||
Node resultNode = sourceNode.selectSingleNode("result");
|
||||
if (resultNode instanceof Element) {
|
||||
Element result = (Element) resultNode;
|
||||
if (result.elements().size() == 1) {
|
||||
|
||||
Node node1 = (Node) result.elements().get(0);
|
||||
if (node1 instanceof Element) {
|
||||
sourceNode = node1;
|
||||
|
||||
sourceNode.getParent().remove(sourceNode);
|
||||
DocumentHelper.createDocument((Element) sourceNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sourceNode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.ArchiveImport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* ArchiveImportParser is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-09
|
||||
*/
|
||||
public class ArchiveImportParser implements XmlNodeParser<ArchiveImport> {
|
||||
String xpath;
|
||||
|
||||
public ArchiveImportParser() {
|
||||
}
|
||||
|
||||
public ArchiveImportParser(final String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArchiveImport parseXmlNode(final Node node) {
|
||||
final Node importNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
|
||||
boolean issuccess = "successful".equals(importNode.valueOf("/import/@status"));
|
||||
final ArrayList<String> messages = new ArrayList<String>();
|
||||
for (final Object o : importNode.selectNodes("/import/errors/error")) {
|
||||
messages.add(((Node) o).getText());
|
||||
}
|
||||
|
||||
return new ArchiveImport(issuccess, messages);
|
||||
}
|
||||
}
|
42
src/main/java/org/rundeck/api/parser/BaseStateParser.java
Normal file
42
src/main/java/org/rundeck/api/parser/BaseStateParser.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.BaseState;
|
||||
import org.rundeck.api.domain.RundeckWFExecState;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:19 PM
|
||||
*/
|
||||
public class BaseStateParser implements XmlNodeParser<BaseState> {
|
||||
public static void parseBaseState(Node targetNode, BaseState state) {
|
||||
state.setEndTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("endTime"))));
|
||||
state.setStartTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("startTime"))));
|
||||
state.setUpdateTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("updateTime"))));
|
||||
|
||||
try {
|
||||
state.setExecutionState(RundeckWFExecState.valueOf(StringUtils.upperCase(targetNode.valueOf
|
||||
("executionState"))));
|
||||
} catch (IllegalArgumentException e) {
|
||||
state.setExecutionState(null);
|
||||
}
|
||||
}
|
||||
|
||||
private String xpath;
|
||||
|
||||
public BaseStateParser() {
|
||||
}
|
||||
|
||||
public BaseStateParser(String xpath) {
|
||||
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseState parseXmlNode(Node node) {
|
||||
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
BaseState baseState = new BaseState();
|
||||
parseBaseState(targetNode, baseState);
|
||||
return baseState;
|
||||
}
|
||||
}
|
29
src/main/java/org/rundeck/api/parser/BaseXpathParser.java
Normal file
29
src/main/java/org/rundeck/api/parser/BaseXpathParser.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
|
||||
/**
|
||||
* BaseXpathParser is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public abstract class BaseXpathParser<T> implements XmlNodeParser<T> {
|
||||
private String xpath;
|
||||
|
||||
public BaseXpathParser() {
|
||||
}
|
||||
|
||||
public BaseXpathParser(String xpath) {
|
||||
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
public abstract T parse(Node node);
|
||||
|
||||
@Override
|
||||
public T parseXmlNode(Node node) {
|
||||
Node selectedNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
return parse(selectedNode);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.DeleteExecutionsResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DeleteExecutionsResponseParser is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-06
|
||||
*/
|
||||
public class DeleteExecutionsResponseParser implements XmlNodeParser<DeleteExecutionsResponse> {
|
||||
private String xpath;
|
||||
|
||||
public DeleteExecutionsResponseParser(final String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override public DeleteExecutionsResponse parseXmlNode(final Node node) {
|
||||
final Node baseNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
|
||||
final DeleteExecutionsResponse response = new DeleteExecutionsResponse();
|
||||
response.setAllsuccessful(Boolean.parseBoolean(baseNode.valueOf("@allsuccessful")));
|
||||
response.setRequestCount(Integer.parseInt(baseNode.valueOf("@requestCount")));
|
||||
response.setSuccessCount(Integer.parseInt(baseNode.valueOf("successful/@count")));
|
||||
|
||||
final Node failedNode = baseNode.selectSingleNode("failed");
|
||||
//parse failures
|
||||
final List<DeleteExecutionsResponse.DeleteFailure> failures = new ArrayList
|
||||
<DeleteExecutionsResponse.DeleteFailure>();
|
||||
int failedCount = 0;
|
||||
if (null != failedNode) {
|
||||
failedCount = Integer.parseInt(baseNode.valueOf("failed/@count"));
|
||||
final List list = baseNode.selectNodes("failed/execution");
|
||||
|
||||
for (final Object o : list) {
|
||||
final Node execNode = (Node) o;
|
||||
final DeleteExecutionsResponse.DeleteFailure deleteFailure =
|
||||
new DeleteExecutionsResponse.DeleteFailure();
|
||||
deleteFailure.setExecutionId(Long.parseLong(execNode.valueOf("@id")));
|
||||
deleteFailure.setMessage(execNode.valueOf("@message"));
|
||||
failures.add(deleteFailure);
|
||||
}
|
||||
}
|
||||
response.setFailedCount(failedCount);
|
||||
response.setFailures(failures);
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -15,12 +15,18 @@
|
|||
*/
|
||||
package org.rundeck.api.parser;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.RundeckExecution;
|
||||
import org.rundeck.api.domain.RundeckJob;
|
||||
import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
|
||||
import org.rundeck.api.domain.RundeckNode;
|
||||
import org.rundeck.api.domain.RundeckNodeIdentity;
|
||||
|
||||
/**
|
||||
* Parser for a single {@link RundeckExecution}
|
||||
|
@ -76,6 +82,26 @@ public class ExecutionParser implements XmlNodeParser<RundeckExecution> {
|
|||
execution.setJob(job);
|
||||
}
|
||||
|
||||
final Node successfulNodes = execNode.selectSingleNode("successfulNodes");
|
||||
if (successfulNodes != null) {
|
||||
final List<RundeckNode> rundeckNodes =
|
||||
new ListParser<RundeckNode>(new NodeParser(), "successfulNodes/node")
|
||||
.parseXmlNode(execNode);
|
||||
execution.setSuccessfulNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
|
||||
}else{
|
||||
execution.setSuccessfulNodes(Collections.<RundeckNodeIdentity>emptySet());
|
||||
}
|
||||
|
||||
final Node failedNodes = execNode.selectSingleNode("failedNodes");
|
||||
if (failedNodes != null) {
|
||||
final List<RundeckNode> rundeckNodes =
|
||||
new ListParser<RundeckNode>(new NodeParser(), "failedNodes/node")
|
||||
.parseXmlNode(execNode);
|
||||
execution.setFailedNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
|
||||
} else {
|
||||
execution.setFailedNodes(Collections.<RundeckNodeIdentity>emptySet());
|
||||
}
|
||||
|
||||
return execution;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:42 PM
|
||||
*/
|
||||
public class ExecutionStateParser implements XmlNodeParser<RundeckExecutionState> {
|
||||
private String xpath;
|
||||
|
||||
public ExecutionStateParser() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpath of the execution element if it is not the root node
|
||||
*/
|
||||
public ExecutionStateParser(String xpath) {
|
||||
this();
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RundeckExecutionState parseXmlNode(Node node) {
|
||||
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
RundeckExecutionState rundeckExecutionState = new RundeckExecutionState();
|
||||
rundeckExecutionState.setExecutionId(Long.valueOf(targetNode.valueOf("@id")));
|
||||
|
||||
WorkflowStateParser.parseWorkflowState(targetNode, rundeckExecutionState);
|
||||
|
||||
|
||||
final List<RundeckNode> rundeckNodes =
|
||||
new ListParser<RundeckNode>(new NodeParser(), "allNodes/nodes/node").parseXmlNode(targetNode);
|
||||
rundeckExecutionState.setAllNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
|
||||
|
||||
|
||||
//node states
|
||||
HashMap<String, List<WorkflowStepContextState>> nodeStates = new HashMap<String, List<WorkflowStepContextState>>();
|
||||
|
||||
for (Object o : targetNode.selectNodes("nodes/node")) {
|
||||
final Node nodeStateNode = (Node) o;
|
||||
final String nodeName = StringUtils.trimToNull(nodeStateNode.valueOf("@name"));
|
||||
if (null != nodeName) {
|
||||
ListParser<WorkflowStepContextState> workflowStepStateListParser
|
||||
= new ListParser<WorkflowStepContextState>(new IndexedWorkflowStepStateParser(rundeckExecutionState, nodeName)
|
||||
, "steps/step");
|
||||
nodeStates.put(nodeName, workflowStepStateListParser.parseXmlNode(nodeStateNode));
|
||||
}
|
||||
}
|
||||
rundeckExecutionState.setNodeStates(nodeStates);
|
||||
|
||||
return rundeckExecutionState;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.WorkflowState;
|
||||
import org.rundeck.api.domain.WorkflowStepContextState;
|
||||
import org.rundeck.api.domain.WorkflowStepState;
|
||||
|
||||
/**
|
||||
* Returns a WorkflowStepContextState by looking up the given Rundeck node's state in the workflow, using the step
|
||||
* context path of the "stepctx" element of the selected DOM node.
|
||||
*/
|
||||
public class IndexedWorkflowStepStateParser implements XmlNodeParser<WorkflowStepContextState> {
|
||||
private final WorkflowState workflowState;
|
||||
private String rundeckNodeName;
|
||||
|
||||
@Override
|
||||
public WorkflowStepContextState parseXmlNode(final Node node) {
|
||||
//look for workflow step state based on node name and stepctx found on the node
|
||||
final String stepctx = StringUtils.trimToNull(node.valueOf("stepctx"));
|
||||
final WorkflowStepState foundStep = lookupContext(stepctx, workflowState);
|
||||
//look up node state for this node
|
||||
if (null != foundStep
|
||||
&& null != foundStep.getNodeStates()
|
||||
&& null != foundStep.getNodeStates().get(rundeckNodeName)) {
|
||||
return foundStep.getNodeStates().get(rundeckNodeName);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* look up the workflow step state for the step context, from the root workflow
|
||||
*
|
||||
* @param stepctx
|
||||
* @param initial
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static WorkflowStepState lookupContext(final String stepctx, final WorkflowState initial) {
|
||||
final String[] parts = stepctx.split("/");
|
||||
//descend workflow steps to find correct step
|
||||
WorkflowState current = initial;
|
||||
WorkflowStepState currentStep = null;
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
final String part = parts[i];
|
||||
final WorkflowStepState workflowStepState = current.getSteps().get(Integer.parseInt(part) - 1);
|
||||
currentStep = workflowStepState;
|
||||
if (i < parts.length - 1) {
|
||||
current = currentStep.getSubWorkflow();
|
||||
}
|
||||
}
|
||||
return currentStep;
|
||||
}
|
||||
|
||||
public IndexedWorkflowStepStateParser(final WorkflowState workflowState, final String rundeckNodeName) {
|
||||
this.workflowState = workflowState;
|
||||
this.rundeckNodeName = rundeckNodeName;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,10 @@ import org.dom4j.Node;
|
|||
import org.rundeck.api.domain.RundeckOutputEntry;
|
||||
import org.rundeck.api.domain.RundeckOutputEntry.RundeckLogLevel;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Parses output message content for API v6
|
||||
*/
|
||||
|
@ -16,15 +20,28 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
|
|||
|
||||
public OutputEntryParser() {
|
||||
super();
|
||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
/**
|
||||
* @param xpath of the event element if it is not the root node
|
||||
*/
|
||||
public OutputEntryParser(String xpath) {
|
||||
super();
|
||||
this();
|
||||
this.xpath = xpath;
|
||||
}
|
||||
static HashSet<String> nonMetaAttributes = new HashSet<String>();
|
||||
static {
|
||||
nonMetaAttributes.add("time");
|
||||
nonMetaAttributes.add("level");
|
||||
nonMetaAttributes.add("user");
|
||||
nonMetaAttributes.add("node");
|
||||
nonMetaAttributes.add("type");
|
||||
nonMetaAttributes.add("log");
|
||||
nonMetaAttributes.add("absolute_type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RundeckOutputEntry parseXmlNode(Node node) {
|
||||
|
@ -38,15 +55,44 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
|
|||
} catch (IllegalArgumentException e) {
|
||||
outputEntry.setLevel(null);
|
||||
}
|
||||
if(null!=entryNode.valueOf("@absolute_time")) {
|
||||
outputEntry.setAbsoluteTime(parseDate(StringUtils.trimToNull(entryNode.valueOf("@absolute_time"))));
|
||||
}
|
||||
|
||||
outputEntry.setUser(StringUtils.trimToNull(entryNode.valueOf("@user")));
|
||||
outputEntry.setCommand(StringUtils.trimToNull(entryNode.valueOf("@command")));
|
||||
outputEntry.setNode(StringUtils.trimToNull(entryNode.valueOf("@node")));
|
||||
outputEntry.setType(StringUtils.trimToNull(entryNode.valueOf("@type")));
|
||||
|
||||
HashMap<String, String> meta = new HashMap<String, String>();
|
||||
List list = entryNode.selectNodes("@*");
|
||||
for (Object node1 : list) {
|
||||
if(node1 instanceof Node) {
|
||||
Node child = (Node) node1;
|
||||
if (!nonMetaAttributes.contains(child.getName())) {
|
||||
meta.put(child.getName(), child.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(meta.size()>0){
|
||||
outputEntry.setMetadata(meta);
|
||||
}
|
||||
outputEntry.setMessage(parseMessage(entryNode));
|
||||
|
||||
return outputEntry;
|
||||
}
|
||||
|
||||
private Date parseDate(String s) {
|
||||
if(null==s){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date parse = dateFormat.parse(s);
|
||||
return parse;
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the message content
|
||||
*/
|
||||
|
@ -54,4 +100,4 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
|
|||
return StringUtils.trimToNull(entryNode.valueOf("@log"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
|
|||
output.setCompleted(Boolean.valueOf(entryNode.valueOf("completed")));
|
||||
output.setExecCompleted(Boolean.valueOf(entryNode.valueOf("execCompleted")));
|
||||
output.setHasFailedNodes(Boolean.valueOf(entryNode.valueOf("hasFailedNodes")));
|
||||
output.setUnmodified(Boolean.valueOf(entryNode.valueOf("unmodified")));
|
||||
|
||||
try {
|
||||
output.setStatus(RundeckExecution.ExecutionStatus
|
||||
|
@ -78,6 +79,10 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
|
|||
} catch (NumberFormatException e) {
|
||||
output.setTotalSize(-1);
|
||||
}
|
||||
if(entryNode.selectSingleNode("filter")!=null){
|
||||
output.setFilterNode(StringUtils.trimToNull(entryNode.valueOf("filter/@nodename")));
|
||||
output.setFilterStep(StringUtils.trimToNull(entryNode.valueOf("filter/@stepctx")));
|
||||
}
|
||||
|
||||
Node entriesListNode = entryNode.selectSingleNode("entries");
|
||||
|
||||
|
@ -93,4 +98,4 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
|
|||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ package org.rundeck.api.parser;
|
|||
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.RundeckApiException;
|
||||
import org.rundeck.api.util.PagedResults;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -38,7 +39,7 @@ import java.util.*;
|
|||
*/
|
||||
public class PagedResultParser<T> implements XmlNodeParser<PagedResults<T>> {
|
||||
ListParser<T> itemParser;
|
||||
String xpath;
|
||||
private String xpath;
|
||||
|
||||
/**
|
||||
* Create a PagedResultParser
|
||||
|
@ -54,7 +55,9 @@ public class PagedResultParser<T> implements XmlNodeParser<PagedResults<T>> {
|
|||
@Override
|
||||
public PagedResults<T> parseXmlNode(Node node) {
|
||||
Node pagedNodeContainer = node.selectSingleNode(xpath);
|
||||
|
||||
if(null==pagedNodeContainer) {
|
||||
throw new RundeckApiException("XML content did not match XPATH expression: " + xpath);
|
||||
}
|
||||
Element el = (Element) pagedNodeContainer;
|
||||
final int max = integerAttribute(el, "max", -1);
|
||||
final int offset = integerAttribute(el, "offset", -1);
|
||||
|
@ -113,4 +116,8 @@ public class PagedResultParser<T> implements XmlNodeParser<PagedResults<T>> {
|
|||
}
|
||||
return parseMax;
|
||||
}
|
||||
|
||||
public String getXpath() {
|
||||
return xpath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProjectConfigParser parses project "config" element contents
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectConfigParser implements XmlNodeParser<ProjectConfig> {
|
||||
private String xpath;
|
||||
|
||||
public ProjectConfigParser() {
|
||||
}
|
||||
|
||||
public ProjectConfigParser(String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectConfig parseXmlNode(Node node) {
|
||||
Node config1 = getXpath() != null ? node.selectSingleNode(getXpath()) : node;
|
||||
ProjectConfig config = new ProjectConfig();
|
||||
List property = config1.selectNodes("property");
|
||||
for (Object o : property) {
|
||||
Node propnode = (Node) o;
|
||||
String key = propnode.valueOf("@key");
|
||||
String value = propnode.valueOf("@value");
|
||||
if (null != key && null != value) {
|
||||
config.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public String getXpath() {
|
||||
return xpath;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.ConfigProperty;
|
||||
|
||||
/**
|
||||
* ProjectConfigPropertyParser parses a {@literal <property/>} element representing
|
||||
* a configuration property.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-07
|
||||
*/
|
||||
public class ProjectConfigPropertyParser implements XmlNodeParser<ConfigProperty> {
|
||||
private String xpath;
|
||||
|
||||
public ProjectConfigPropertyParser() {
|
||||
}
|
||||
|
||||
public ProjectConfigPropertyParser(final String xpath) {
|
||||
this.setXpath(xpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigProperty parseXmlNode(final Node node) {
|
||||
final Node propnode = getXpath() != null ? node.selectSingleNode(getXpath()) : node;
|
||||
final String key = propnode.valueOf("@key");
|
||||
final String value = propnode.valueOf("@value");
|
||||
final ConfigProperty config = new ConfigProperty();
|
||||
config.setKey(key);
|
||||
config.setValue(value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public String getXpath() {
|
||||
return xpath;
|
||||
}
|
||||
|
||||
public void setXpath(final String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@ public class ProjectParser implements XmlNodeParser<RundeckProject> {
|
|||
|
||||
@Override
|
||||
public RundeckProject parseXmlNode(Node node) {
|
||||
Node projectNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
Node projectNode = getXpath() != null ? node.selectSingleNode(getXpath()) : node;
|
||||
|
||||
RundeckProject project = new RundeckProject();
|
||||
|
||||
|
@ -53,4 +53,7 @@ public class ProjectParser implements XmlNodeParser<RundeckProject> {
|
|||
return project;
|
||||
}
|
||||
|
||||
protected String getXpath() {
|
||||
return xpath;
|
||||
}
|
||||
}
|
||||
|
|
36
src/main/java/org/rundeck/api/parser/ProjectParserV11.java
Normal file
36
src/main/java/org/rundeck/api/parser/ProjectParserV11.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProjectParserV11 supports embedded "config" element.
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectParserV11 extends ProjectParser {
|
||||
public ProjectParserV11() {
|
||||
}
|
||||
|
||||
public ProjectParserV11(final String xpath) {
|
||||
super(xpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RundeckProject parseXmlNode(final Node node) {
|
||||
final RundeckProject rundeckProject = super.parseXmlNode(node);
|
||||
final Node projectNode = getXpath() != null ? node.selectSingleNode(getXpath()) : node;
|
||||
final Node config1 = projectNode.selectSingleNode("config");
|
||||
if (config1 == null) {
|
||||
return rundeckProject;
|
||||
}
|
||||
|
||||
rundeckProject.setProjectConfig(new ProjectConfigParser().parseXmlNode(config1));
|
||||
|
||||
return rundeckProject;
|
||||
}
|
||||
}
|
33
src/main/java/org/rundeck/api/parser/RundeckTokenParser.java
Normal file
33
src/main/java/org/rundeck/api/parser/RundeckTokenParser.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.RundeckToken;
|
||||
|
||||
/**
|
||||
* RundeckTokenParser is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class RundeckTokenParser implements XmlNodeParser<RundeckToken> {
|
||||
String xpath;
|
||||
|
||||
public RundeckTokenParser() {
|
||||
}
|
||||
|
||||
public RundeckTokenParser(String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RundeckToken parseXmlNode(Node node) {
|
||||
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
RundeckToken rundeckToken = new RundeckToken();
|
||||
String token = targetNode.valueOf("@id");
|
||||
String user = targetNode.valueOf("@user");
|
||||
rundeckToken.setToken(token);
|
||||
rundeckToken.setUser(user);
|
||||
|
||||
return rundeckToken;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.BaseKeyResource;
|
||||
import org.rundeck.api.domain.KeyResource;
|
||||
|
||||
/**
|
||||
* SSHKeyResourceParser is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class SSHKeyResourceParser extends BaseXpathParser<KeyResource> implements XmlNodeParser<KeyResource> {
|
||||
public SSHKeyResourceParser() {
|
||||
}
|
||||
|
||||
public SSHKeyResourceParser(String xpath) {
|
||||
super(xpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyResource parse(Node node) {
|
||||
return BaseKeyResource.from(new StorageResourceParser().parse(node));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.BaseStorageResource;
|
||||
import org.rundeck.api.domain.StorageResource;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* StorageResourceParser is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-04-04
|
||||
*/
|
||||
public class StorageResourceParser extends BaseXpathParser<StorageResource> {
|
||||
private BaseStorageResource holder;
|
||||
public StorageResourceParser() {
|
||||
|
||||
}
|
||||
public StorageResourceParser(BaseStorageResource holder){
|
||||
this.holder=holder;
|
||||
}
|
||||
|
||||
public StorageResourceParser(String xpath) {
|
||||
super(xpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageResource parse(Node node) {
|
||||
String path = node.valueOf("@path");
|
||||
String type = node.valueOf("@type");
|
||||
String url = node.valueOf("@url");
|
||||
BaseStorageResource storageResource = null == holder ? new BaseStorageResource() : holder;
|
||||
storageResource.setDirectory("directory".equals(type));
|
||||
storageResource.setPath(path);
|
||||
storageResource.setUrl(url);
|
||||
|
||||
if (storageResource.isDirectory()) {
|
||||
if (node.selectSingleNode("contents") != null) {
|
||||
storageResource.setDirectoryContents(new ListParser<StorageResource>(new StorageResourceParser(),
|
||||
"contents/resource").parseXmlNode(node));
|
||||
}
|
||||
} else {
|
||||
String name = node.valueOf("@name");
|
||||
storageResource.setName(name);
|
||||
|
||||
Node meta = node.selectSingleNode("resource-meta");
|
||||
HashMap<String, String> metamap = new HashMap<String, String>();
|
||||
if (null != meta) {
|
||||
Element metaEl = (Element) meta;
|
||||
for (Object o : metaEl.elements()) {
|
||||
Element sub = (Element) o;
|
||||
metamap.put(sub.getName(), sub.getText().trim());
|
||||
}
|
||||
}
|
||||
storageResource.setMetadata(metamap);
|
||||
}
|
||||
return storageResource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:44 PM
|
||||
*/
|
||||
public class WorkflowStateParser implements XmlNodeParser<WorkflowState> {
|
||||
private String xpath;
|
||||
|
||||
public WorkflowStateParser() {
|
||||
}
|
||||
|
||||
public WorkflowStateParser(String xpath) {
|
||||
this();
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
private static final ThreadLocal<DateFormat> w3cDateFormat = new ThreadLocal<DateFormat>() {
|
||||
protected DateFormat initialValue() {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
||||
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return fmt;
|
||||
}
|
||||
};
|
||||
public static Date parseDate(String s) {
|
||||
if (null == s) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date parse = w3cDateFormat.get().parse(s);
|
||||
return parse;
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int integerValue(final String value, final int defValue) {
|
||||
int parseMax = defValue;
|
||||
try {
|
||||
parseMax = null != value ? Integer.parseInt(value) : defValue;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return parseMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkflowState parseXmlNode(Node node) {
|
||||
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
WorkflowState state = new WorkflowState();
|
||||
parseWorkflowState(targetNode, state);
|
||||
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the workflow state components from the given dom node
|
||||
* @param targetNode
|
||||
* @param state
|
||||
*/
|
||||
public static void parseWorkflowState(Node targetNode, WorkflowState state) {
|
||||
BaseStateParser.parseBaseState(targetNode, state);
|
||||
|
||||
state.setStepCount(integerValue(StringUtils.trimToNull(targetNode.valueOf("stepCount")), 0));
|
||||
|
||||
final List<RundeckNode> rundeckNodes =
|
||||
new ListParser<RundeckNode>(new NodeParser(), "targetNodes/nodes/node").parseXmlNode(targetNode);
|
||||
state.setTargetNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
|
||||
|
||||
//steps
|
||||
state.setSteps(new ListParser<WorkflowStepState>(new WorkflowStepStateParser(),
|
||||
"steps/step").parseXmlNode(targetNode));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.WorkflowStepContextState;
|
||||
import org.rundeck.api.domain.WorkflowStepState;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:39 PM
|
||||
*/
|
||||
public class WorkflowStepContextStateParser implements XmlNodeParser<WorkflowStepContextState> {
|
||||
WorkflowStepContextState inherit;
|
||||
|
||||
public WorkflowStepContextStateParser(WorkflowStepContextState inherit) {
|
||||
this.inherit = inherit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkflowStepContextState parseXmlNode(Node node) {
|
||||
WorkflowStepContextState workflowStepState = new WorkflowStepContextState();
|
||||
if(null!=inherit) {
|
||||
workflowStepState.setStepNum(inherit.getStepNum());
|
||||
workflowStepState.setStepContextId(inherit.getStepContextId());
|
||||
}
|
||||
BaseStateParser.parseBaseState(node, workflowStepState);
|
||||
return workflowStepState;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
import org.rundeck.api.domain.BaseState;
|
||||
import org.rundeck.api.domain.WorkflowStepContextState;
|
||||
import org.rundeck.api.domain.WorkflowStepState;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:09 PM
|
||||
*/
|
||||
public class WorkflowStepStateParser implements XmlNodeParser<WorkflowStepState> {
|
||||
private String xpath;
|
||||
|
||||
public WorkflowStepStateParser(final String xpath) {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
public WorkflowStepStateParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkflowStepState parseXmlNode(final Node node) {
|
||||
final Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
|
||||
final WorkflowStepState state = new WorkflowStepState();
|
||||
|
||||
BaseStateParser.parseBaseState(targetNode, state);
|
||||
state.setStepContextId(StringUtils.trimToNull(targetNode.valueOf("@stepctx")));
|
||||
state.setStepNum(Integer.valueOf(targetNode.valueOf("@id")));
|
||||
state.setNodeStep(Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("nodeStep"))));
|
||||
if (Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("hasSubworkflow")))) {
|
||||
//parse sub workflow
|
||||
state.setSubWorkflow(new WorkflowStateParser("workflow").parseXmlNode(targetNode));
|
||||
}
|
||||
if (Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("nodeStep")))) {
|
||||
//node states
|
||||
final HashMap<String, WorkflowStepContextState> nodeStates = new HashMap<String, WorkflowStepContextState>();
|
||||
for (final Object o : targetNode.selectNodes("nodeStates/nodeState")) {
|
||||
final Node nodeStateNode = (Node) o;
|
||||
final String nodeName = StringUtils.trimToNull(nodeStateNode.valueOf("@name"));
|
||||
if (null != nodeName) {
|
||||
nodeStates.put(nodeName, new WorkflowStepContextStateParser(state).parseXmlNode(nodeStateNode));
|
||||
}
|
||||
}
|
||||
state.setNodeStates(nodeStates);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.rundeck.api.util;
|
||||
|
||||
import org.apache.http.entity.ContentProducer;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* DocumentContentProducer writes XML document to a stream
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class DocumentContentProducer implements ContentProducer {
|
||||
Document document;
|
||||
private OutputFormat format;
|
||||
|
||||
public DocumentContentProducer(final Document document, final OutputFormat format) {
|
||||
this.document = document;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public DocumentContentProducer(final Document document) {
|
||||
this.document = document;
|
||||
format = new OutputFormat("", false, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(final OutputStream outstream) throws IOException {
|
||||
|
||||
final XMLWriter xmlWriter = new XMLWriter(outstream, format);
|
||||
xmlWriter.write(document);
|
||||
xmlWriter.flush();
|
||||
}
|
||||
}
|
|
@ -7,13 +7,10 @@ The library is hosted on the [Maven Central Repository|http://search.maven.org/]
|
|||
|
||||
You can see all versions and download the files with this query : [g:"org.rundeck" AND a:"rundeck-api-java-client"|http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.rundeck%22%20AND%20a%3A%22rundeck-api-java-client%22].
|
||||
|
||||
Alternatively, you can download [releases|https://oss.sonatype.org/content/repositories/releases/org/rundeck/rundeck-api-java-client/] or [snapshots|https://oss.sonatype.org/content/repositories/snapshots/org/rundeck/rundeck-api-java-client/] from [Sonatype Nexus OSS instance|https://oss.sonatype.org/] (which is then synchronized to Maven Central).
|
||||
Alternatively, you can download [releases|https://oss.sonatype.org/content/repositories/releases/org/rundeck/rundeck-api-java-client/] from [Sonatype Nexus OSS instance|https://oss.sonatype.org/] (which is then synchronized to Maven Central).
|
||||
|
||||
h2. Manual download
|
||||
|
||||
If you want to use this library from a [scripting language|./scripting.html], it is often easier to download a single *jar* file with all dependencies included (named "*rundeck-api-java-client-VERSION-jar-with-dependencies.jar *")
|
||||
|
||||
You can download such files on GitHub : [https://github.com/vbehar/rundeck-api-java-client/downloads] (for each release)
|
||||
|
||||
You can also download the latest version (not yet released) on Jenkins : [https://rundeck-api-java-client.ci.cloudbees.com/job/master/lastSuccessfulBuild/artifact/target/]
|
||||
|
||||
You can download such files on GitHub : [https://github.com/rundeck/rundeck-api-java-client/releases] (for each release)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
h1. Using the RunDeck API from Groovy scripts
|
||||
h1. Using the Rundeck API from Groovy scripts
|
||||
|
||||
Here are some examples of what you can do with this lib and a few lines of [Groovy|http://groovy.codehaus.org/].
|
||||
|
||||
|
@ -11,16 +11,16 @@ Save the following script in a file named "{{rundeck.groovy}}", and execute it w
|
|||
|
||||
{code}
|
||||
// we use Grape (Ivy) to download the lib (and its dependencies) from Maven Central Repository
|
||||
@Grab(group='org.rundeck', module='rundeck-api-java-client', version='2.0')
|
||||
@Grab(group='org.rundeck', module='rundeck-api-java-client', version='12.0')
|
||||
import org.rundeck.api.RundeckClient
|
||||
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
println "RunDeck uptime : ${rundeck.systemInfo.uptime}"
|
||||
println "All RunDeck projects : ${rundeck.projects}"
|
||||
println "All RunDeck nodes : ${rundeck.nodes}"
|
||||
println "All RunDeck jobs : ${rundeck.jobs}"
|
||||
println "All RunDeck running executions : ${rundeck.runningExecutions}"
|
||||
println "Rundeck uptime : ${rundeck.systemInfo.uptime}"
|
||||
println "All Rundeck projects : ${rundeck.projects}"
|
||||
println "All Rundeck nodes : ${rundeck.nodes}"
|
||||
println "All Rundeck jobs : ${rundeck.jobs}"
|
||||
println "All Rundeck running executions : ${rundeck.runningExecutions}"
|
||||
{code}
|
||||
|
||||
You can also [download|./download.html] the lib and all its dependencies in 1 big jar file, and add it to your classpath before running your script : save the following script in a file named "{{rundeck.groovy}}", and execute it with "{{groovy -cp /path/to/rundeck-api-java-client-VERSION-jar-with-dependencies.jar rundeck.groovy}}".
|
||||
|
@ -28,34 +28,34 @@ You can also [download|./download.html] the lib and all its dependencies in 1 bi
|
|||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
println "RunDeck uptime : ${rundeck.systemInfo.uptime}"
|
||||
println "All RunDeck projects : ${rundeck.projects}"
|
||||
println "All RunDeck nodes : ${rundeck.nodes}"
|
||||
println "All RunDeck jobs : ${rundeck.jobs}"
|
||||
println "All RunDeck running executions : ${rundeck.runningExecutions}"
|
||||
println "Rundeck uptime : ${rundeck.systemInfo.uptime}"
|
||||
println "All Rundeck projects : ${rundeck.projects}"
|
||||
println "All Rundeck nodes : ${rundeck.nodes}"
|
||||
println "All Rundeck jobs : ${rundeck.jobs}"
|
||||
println "All Rundeck running executions : ${rundeck.runningExecutions}"
|
||||
{code}
|
||||
|
||||
h2. Authentication
|
||||
|
||||
Starting with RunDeck API 2, there are 2 ways to authenticate :
|
||||
Starting with Rundeck API 2, there are 2 ways to authenticate :
|
||||
* the *login-based authentication* : with your login and password
|
||||
* the *token-based authentication* : with a unique token that you can generate from the RunDeck webUI
|
||||
* the *token-based authentication* : with a unique token that you can generate from the Rundeck webUI
|
||||
|
||||
{code}
|
||||
// using login-based authentication (admin/admin is the default login/password for a new RunDeck instance) :
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin");
|
||||
// using login-based authentication (admin/admin is the default login/password for a new Rundeck instance) :
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// using token-based authentication :
|
||||
rundeck = new RundeckClient("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").token("PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD").build()
|
||||
{code}
|
||||
|
||||
h2. Running a job
|
||||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// find a job from its name, group and project
|
||||
job = rundeck.findJob("my-project", "main-group/sub-group", "job-name")
|
||||
|
@ -80,9 +80,9 @@ h2. Running an ad-hoc command
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of the "uptime" command on the RunDeck server
|
||||
// trigger the execution of the "uptime" command on the Rundeck server
|
||||
execution = rundeck.triggerAdhocCommand("my-project", "uptime")
|
||||
|
||||
// run the "uptime" command on all unix nodes
|
||||
|
@ -93,9 +93,9 @@ h2. Running an ad-hoc script
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of a custom bash script on the RunDeck server
|
||||
// trigger the execution of a custom bash script on the Rundeck server
|
||||
execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
|
||||
|
||||
// run a bash script (with options) on all unix nodes
|
||||
|
@ -106,7 +106,7 @@ h2. Exporting jobs
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
rundeck.exportJobsToFile("/tmp/jobs.xml", "xml", "my-project")
|
||||
rundeck.exportJobToFile("/tmp/job.yaml", "yaml", "job-id")
|
||||
|
@ -116,7 +116,7 @@ h2. Importing jobs
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = new RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
result = rundeck.importJobs("/tmp/jobs.xml", "xml")
|
||||
println "${result.succeededJobs.size} jobs successfully imported, ${result.skippedJobs.size} jobs skipped, and ${result.failedJobs.size} jobs failed"
|
||||
|
@ -124,5 +124,5 @@ println "${result.succeededJobs.size} jobs successfully imported, ${result.skipp
|
|||
|
||||
h2. And more...
|
||||
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your RunDeck instance...
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your Rundeck instance...
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
h1. Using the RunDeck API from JRuby scripts
|
||||
h1. Using the Rundeck API from JRuby scripts
|
||||
|
||||
Here are some examples of what you can do with this lib and a few lines of [Ruby|http://www.jruby.org/] (for the rubyist that don't fear running on the JVM !)
|
||||
|
||||
|
@ -14,13 +14,13 @@ require 'java'
|
|||
require '/path/to/rundeck-api-java-client-VERSION-jar-with-dependencies.jar'
|
||||
import org.rundeck.api.RundeckClient
|
||||
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
puts "RunDeck uptime : #{rundeck.systemInfo.uptime}"
|
||||
puts "All RunDeck projects : #{rundeck.projects}"
|
||||
puts "All RunDeck nodes : #{rundeck.nodes}"
|
||||
puts "All RunDeck jobs : #{rundeck.jobs}"
|
||||
puts "All RunDeck running executions : #{rundeck.runningExecutions}"
|
||||
puts "Rundeck uptime : #{rundeck.systemInfo.uptime}"
|
||||
puts "All Rundeck projects : #{rundeck.projects}"
|
||||
puts "All Rundeck nodes : #{rundeck.nodes}"
|
||||
puts "All Rundeck jobs : #{rundeck.jobs}"
|
||||
puts "All Rundeck running executions : #{rundeck.runningExecutions}"
|
||||
{code}
|
||||
|
||||
You can also add the library to the classpath : save the following script in a file named "{{rundeck.rb}}", and execute it with "{{jruby -rjava -J-cp /path/to/rundeck-api-java-client-VERSION-jar-with-dependencies.jar rundeck.rb}}".
|
||||
|
@ -28,27 +28,27 @@ You can also add the library to the classpath : save the following script in a f
|
|||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
puts "RunDeck uptime : #{rundeck.systemInfo.uptime}"
|
||||
puts "All RunDeck projects : #{rundeck.projects}"
|
||||
puts "All RunDeck nodes : #{rundeck.nodes}"
|
||||
puts "All RunDeck jobs : #{rundeck.jobs}"
|
||||
puts "All RunDeck running executions : #{rundeck.runningExecutions}"
|
||||
puts "Rundeck uptime : #{rundeck.systemInfo.uptime}"
|
||||
puts "All Rundeck projects : #{rundeck.projects}"
|
||||
puts "All Rundeck nodes : #{rundeck.nodes}"
|
||||
puts "All Rundeck jobs : #{rundeck.jobs}"
|
||||
puts "All Rundeck running executions : #{rundeck.runningExecutions}"
|
||||
{code}
|
||||
|
||||
h2. Authentication
|
||||
|
||||
Starting with RunDeck API 2, there are 2 ways to authenticate :
|
||||
Starting with Rundeck API 2, there are 2 ways to authenticate :
|
||||
* the *login-based authentication* : with your login and password
|
||||
* the *token-based authentication* : with a unique token that you can generate from the RunDeck webUI
|
||||
* the *token-based authentication* : with a unique token that you can generate from the Rundeck webUI
|
||||
|
||||
{code}
|
||||
// using login-based authentication (admin/admin is the default login/password for a new RunDeck instance) :
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin");
|
||||
// using login-based authentication (admin/admin is the default login/password for a new Rundeck instance) :
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// using token-based authentication :
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").token("PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD").build()
|
||||
{code}
|
||||
|
||||
h2. Running a job
|
||||
|
@ -58,7 +58,7 @@ import org.rundeck.api.RundeckClient
|
|||
import org.rundeck.api.OptionsBuilder
|
||||
import org.rundeck.api.NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// find a job from its name, group and project
|
||||
job = rundeck.findJob("my-project", "main-group/sub-group", "job-name")
|
||||
|
@ -85,9 +85,9 @@ h2. Running an ad-hoc command
|
|||
import org.rundeck.api.RundeckClient
|
||||
import org.rundeck.api.NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of the "uptime" command on the RunDeck server
|
||||
// trigger the execution of the "uptime" command on the Rundeck server
|
||||
execution = rundeck.triggerAdhocCommand("my-project", "uptime")
|
||||
|
||||
// run the "uptime" command on all unix nodes
|
||||
|
@ -101,9 +101,9 @@ import org.rundeck.api.RundeckClient
|
|||
import org.rundeck.api.OptionsBuilder
|
||||
import org.rundeck.api.NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of a custom bash script on the RunDeck server
|
||||
// trigger the execution of a custom bash script on the Rundeck server
|
||||
execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
|
||||
|
||||
// run a bash script (with options) on all unix nodes
|
||||
|
@ -114,7 +114,7 @@ h2. Exporting jobs
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
rundeck.exportJobsToFile("/tmp/jobs.xml", "xml", "my-project")
|
||||
rundeck.exportJobToFile("/tmp/job.yaml", "yaml", "job-id")
|
||||
|
@ -124,7 +124,7 @@ h2. Importing jobs
|
|||
|
||||
{code}
|
||||
import org.rundeck.api.RundeckClient
|
||||
rundeck = RundeckClient.new("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
result = rundeck.importJobs("/tmp/jobs.xml", "xml")
|
||||
puts "#{result.succeededJobs.size} jobs successfully imported, #{result.skippedJobs.size} jobs skipped, and #{result.failedJobs.size} jobs failed"
|
||||
|
@ -132,5 +132,5 @@ puts "#{result.succeededJobs.size} jobs successfully imported, #{result.skippedJ
|
|||
|
||||
h2. And more...
|
||||
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your RunDeck instance...
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your Rundeck instance...
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
h1. Using the RunDeck API from Jython scripts
|
||||
h1. Using the Rundeck API from Jython scripts
|
||||
|
||||
Here are some examples of what you can do with this lib and a few lines of [Python|http://www.jython.org/] (for the pythonist that don't fear running on the JVM !)
|
||||
|
||||
|
@ -12,27 +12,27 @@ Save the following script in a file named "{{rundeck.py}}", and execute it with
|
|||
{code}
|
||||
from org.rundeck.api import RundeckClient
|
||||
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
print("RunDeck uptime : %s" % rundeck.systemInfo.uptime)
|
||||
print("All RunDeck projects : %s" % rundeck.projects)
|
||||
print("All RunDeck nodes : %s" % rundeck.nodes)
|
||||
print("All RunDeck jobs : %s" % rundeck.jobs)
|
||||
print("All RunDeck running executions : %s" % rundeck.runningExecutions)
|
||||
print("Rundeck uptime : %s" % rundeck.systemInfo.uptime)
|
||||
print("All Rundeck projects : %s" % rundeck.projects)
|
||||
print("All Rundeck nodes : %s" % rundeck.nodes)
|
||||
print("All Rundeck jobs : %s" % rundeck.jobs)
|
||||
print("All Rundeck running executions : %s" % rundeck.runningExecutions)
|
||||
{code}
|
||||
|
||||
h2. Authentication
|
||||
|
||||
Starting with RunDeck API 2, there are 2 ways to authenticate :
|
||||
Starting with Rundeck API 2, there are 2 ways to authenticate :
|
||||
* the *login-based authentication* : with your login and password
|
||||
* the *token-based authentication* : with a unique token that you can generate from the RunDeck webUI
|
||||
* the *token-based authentication* : with a unique token that you can generate from the Rundeck webUI
|
||||
|
||||
{code}
|
||||
// using login-based authentication (admin/admin is the default login/password for a new RunDeck instance) :
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin");
|
||||
// using login-based authentication (admin/admin is the default login/password for a new Rundeck instance) :
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// using token-based authentication :
|
||||
rundeck = RundeckClient("http://localhost:4440", "PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD");
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").token("PDDNKo5VE29kpk4prOUDr2rsKdRkEvsD").build()
|
||||
{code}
|
||||
|
||||
h2. Running a job
|
||||
|
@ -42,7 +42,7 @@ from org.rundeck.api import RundeckClient
|
|||
from org.rundeck.api import OptionsBuilder
|
||||
from org.rundeck.api import NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// find a job from its name, group and project
|
||||
job = rundeck.findJob("my-project", "main-group/sub-group", "job-name")
|
||||
|
@ -69,9 +69,9 @@ h2. Running an ad-hoc command
|
|||
from org.rundeck.api import RundeckClient
|
||||
from org.rundeck.api import NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of the "uptime" command on the RunDeck server
|
||||
// trigger the execution of the "uptime" command on the Rundeck server
|
||||
execution = rundeck.triggerAdhocCommand("my-project", "uptime")
|
||||
|
||||
// run the "uptime" command on all unix nodes
|
||||
|
@ -85,9 +85,9 @@ from org.rundeck.api import RundeckClient
|
|||
from org.rundeck.api import OptionsBuilder
|
||||
from org.rundeck.api import NodeFiltersBuilder
|
||||
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
// trigger the execution of a custom bash script on the RunDeck server
|
||||
// trigger the execution of a custom bash script on the Rundeck server
|
||||
execution = rundeck.triggerAdhocScript("my-project", "/tmp/my-script.sh")
|
||||
|
||||
// run a bash script (with options) on all unix nodes
|
||||
|
@ -98,7 +98,7 @@ h2. Exporting jobs
|
|||
|
||||
{code}
|
||||
from org.rundeck.api import RundeckClient
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
rundeck.exportJobsToFile("/tmp/jobs.xml", "xml", "my-project")
|
||||
rundeck.exportJobToFile("/tmp/job.yaml", "yaml", "job-id")
|
||||
|
@ -108,7 +108,7 @@ h2. Importing jobs
|
|||
|
||||
{code}
|
||||
from org.rundeck.api import RundeckClient
|
||||
rundeck = RundeckClient("http://localhost:4440", "admin", "admin")
|
||||
rundeck = RundeckClient.builder().url("http://localhost:4440").login("admin", "admin").build()
|
||||
|
||||
result = rundeck.importJobs("/tmp/jobs.xml", "xml")
|
||||
print("%s jobs successfully imported, %s jobs skipped, and %s jobs failed" % (result.succeededJobs.size, result.skippedJobs.size, result.failedJobs.size))
|
||||
|
@ -116,5 +116,5 @@ print("%s jobs successfully imported, %s jobs skipped, and %s jobs failed" % (re
|
|||
|
||||
h2. And more...
|
||||
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your RunDeck instance...
|
||||
See the API documentation of the [RundeckClient|./apidocs/reference/org/rundeck/api/RundeckClient.html] class for more interactions with your Rundeck instance...
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
h1. Status of the implementation of the RunDeck API
|
||||
h1. Status of the implementation of the Rundeck API
|
||||
|
||||
h2. RunDeck API version 1
|
||||
h2. Rundeck API version 1
|
||||
|
||||
[Documentation of the RunDeck API version 1|http://rundeck.org/1.2.1/RunDeck-Guide.html#rundeck-api]
|
||||
[Documentation of the Rundeck API version 1|http://rundeck.org/1.2.1/Rundeck-Guide.html#rundeck-api]
|
||||
|
||||
* Login-based authentication - OK
|
||||
* System Info - OK
|
||||
|
@ -26,60 +26,98 @@ h2. RunDeck API version 1
|
|||
* Listing Resources - OK
|
||||
* Getting Resource Info - OK
|
||||
|
||||
h2. RunDeck API version 2
|
||||
h2. Rundeck API version 2
|
||||
|
||||
[Documentation of the RunDeck API version 2|http://rundeck.org/1.3.2/api/index.html]
|
||||
[Documentation of the Rundeck API version 2|http://rundeck.org/1.3.2/api/index.html]
|
||||
|
||||
* Token-based authentication - OK
|
||||
* Listing Jobs for a Project - *TODO*
|
||||
* Updating and Listing Resources for a Project - *TODO*
|
||||
* Refreshing Resources for a Project - *TODO*
|
||||
|
||||
h2. RunDeck API version 3
|
||||
h2. Rundeck API version 3
|
||||
|
||||
[Documentation of the RunDeck API version 3|http://rundeck.org/1.4.2/api/index.html]
|
||||
[Documentation of the Rundeck API version 3|http://rundeck.org/1.4.2/api/index.html]
|
||||
|
||||
* (only updates to Resource endpoints) - *TODO*
|
||||
|
||||
h2. RunDeck API version 4
|
||||
h2. Rundeck API version 4
|
||||
|
||||
[Documentation of the RunDeck API version 4|http://rundeck.org/1.4.3/api/index.html]
|
||||
[Documentation of the Rundeck API version 4|http://rundeck.org/1.4.3/api/index.html]
|
||||
|
||||
* Running Adhoc Script URLs - *TODO*
|
||||
|
||||
h2. RunDeck API version 5
|
||||
h2. Rundeck API version 5
|
||||
|
||||
[Documentation of the RunDeck API version 5|http://rundeck.org/1.4.4/api/index.html]
|
||||
[Documentation of the Rundeck API version 5|http://rundeck.org/1.4.4/api/index.html]
|
||||
|
||||
* Bulk Job Delete - OK
|
||||
* Execution Output - OK
|
||||
* Execution Query - OK
|
||||
* History list query - OK
|
||||
|
||||
h2. RunDeck API version 6
|
||||
h2. Rundeck API version 6
|
||||
|
||||
[Documentation of the RunDeck API version 6|http://rundeck.org/1.5/api/index.html]
|
||||
[Documentation of the Rundeck API version 6|http://rundeck.org/1.5/api/index.html]
|
||||
|
||||
* Execution Output format fixed - OK
|
||||
|
||||
h2. RunDeck API version 7
|
||||
h2. Rundeck API version 7
|
||||
|
||||
[Documentation of the RunDeck API version 7|http://rundeck.org/1.5.3/api/index.html]
|
||||
[Documentation of the Rundeck API version 7|http://rundeck.org/1.5.3/api/index.html]
|
||||
|
||||
* Incubator for cluster mode job takeover - *TODO*
|
||||
|
||||
h2. RunDeck API version 8
|
||||
h2. Rundeck API version 8
|
||||
|
||||
[Documentation of the RunDeck API version 8|http://rundeck.org/1.6.0/api/index.html]
|
||||
[Documentation of the Rundeck API version 8|http://rundeck.org/1.6.0/api/index.html]
|
||||
|
||||
* scriptInterpreter addition to run script and run url - OK
|
||||
* project parameter added to jobs import - OK
|
||||
|
||||
|
||||
h2. RunDeck API version 9
|
||||
h2. Rundeck API version 9
|
||||
|
||||
[Documentation of the RunDeck API version 9|http://rundeck.org/1.6.1/api/index.html]
|
||||
[Documentation of the Rundeck API version 9|http://rundeck.org/1.6.1/api/index.html]
|
||||
|
||||
* list running executions across all projects - OK
|
||||
* include project name in execution results - OK
|
||||
* Add uuidOption parameter to allow removing imported UUIDs to avoid creation conflicts - OK
|
||||
|
||||
h2. Rundeck API version 10
|
||||
|
||||
[Documentation of the Rundeck API version 10|http://rundeck.org/2.0.0/api/index.html]
|
||||
|
||||
* Execution State - Retrieve workflow step and node state information - OK
|
||||
* Execution Output with State - Retrieve log output with state change information - OK
|
||||
* Execution Output - Retrieve log output for a particular node or step - OK
|
||||
* Execution Info - added successfulNodes and failedNodes detail. - OK
|
||||
* Deprecation: Remove methods deprecated until version 10. - OK
|
||||
|
||||
|
||||
h2. Rundeck API version 11
|
||||
|
||||
[Documentation of the Rundeck API version 11|http://rundeck.org/2.1.0/api/index.html]
|
||||
|
||||
* Project creation - OK
|
||||
* Get Project configuration - OK
|
||||
* Set Project configuration - OK
|
||||
* Get/Set Project configuration keys - OK
|
||||
* Delete project - OK
|
||||
* Export project archive - OK
|
||||
* Import project archive - OK
|
||||
* Key file upload - OK
|
||||
* Key file delete - OK
|
||||
* Key file list - OK
|
||||
* Key file get - OK
|
||||
* API Token create - OK
|
||||
* API Token list - OK
|
||||
* API Token delete - OK
|
||||
|
||||
h2. Rundeck API version 12
|
||||
|
||||
[Documentation of the Rundeck API version 12|http://rundeck.org/2.2.0/api/index.html]
|
||||
|
||||
* Bulk delete executions - OK
|
||||
* Delete execution - OK
|
||||
* Delete all executions for a job - OK
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
</skin>
|
||||
<body>
|
||||
<breadcrumbs>
|
||||
<item name="RunDeck" href="http://rundeck.org" />
|
||||
<item name="RunDeck API - Java Client" href="" />
|
||||
<item name="Rundeck" href="http://rundeck.org" />
|
||||
<item name="Rundeck API - Java Client" href="" />
|
||||
</breadcrumbs>
|
||||
<menu name="${project.name}">
|
||||
<item name="Introduction" href="index.html" />
|
||||
|
@ -46,7 +46,7 @@
|
|||
<item name="Jython" href="jython.html" />
|
||||
</menu>
|
||||
<!-- <menu name="Older versions">
|
||||
<item name="1.x (RunDeck 1.2)" href="1.x/index.html" />
|
||||
<item name="1.x (Rundeck 1.2)" href="1.x/index.html" />
|
||||
</menu> -->
|
||||
<menu ref="reports" />
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package org.rundeck.api;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.query.ExecutionQuery;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ExecutionQueryParametersTest is ...
|
||||
*
|
||||
* @author Greg Schueler <greg@simplifyops.com>
|
||||
* @since 2014-11-07
|
||||
*/
|
||||
public class ExecutionQueryParametersTest {
|
||||
|
||||
@Test
|
||||
public void stringParameter() {
|
||||
ExecutionQuery.Builder description = ExecutionQuery.builder().description("a description");
|
||||
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||
description.build()
|
||||
);
|
||||
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||
Assert.assertEquals("?descFilter=a+description", param.toString());
|
||||
}
|
||||
@Test
|
||||
public void listParameter() {
|
||||
ExecutionQuery.Builder description = ExecutionQuery.builder().excludeJobList(
|
||||
Arrays.asList(
|
||||
"a",
|
||||
"b"
|
||||
)
|
||||
);
|
||||
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||
description.build()
|
||||
);
|
||||
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||
Assert.assertEquals("?excludeJobListFilter=a&excludeJobListFilter=b", param.toString());
|
||||
}
|
||||
@Test
|
||||
public void dateParameter() {
|
||||
ExecutionQuery.Builder description = ExecutionQuery.builder().end(
|
||||
new Date(1347581178168L)
|
||||
);
|
||||
ExecutionQueryParameters executionQueryParameters = new ExecutionQueryParameters(
|
||||
description.build()
|
||||
);
|
||||
ApiPathBuilder param = new ApiPathBuilder("").param(executionQueryParameters);
|
||||
//nb: timezone should be GMT
|
||||
//2012-09-14T00:06:18Z
|
||||
Assert.assertEquals("?end=2012-09-14T00%3A06%3A18Z", param.toString());
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,41 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* ProjectConfigGeneratorTest is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectConfigGeneratorTest {
|
||||
@Test
|
||||
public void generate() throws Exception {
|
||||
ProjectConfig config = new ProjectConfig();
|
||||
config.setProperty("abc", "123");
|
||||
config.setProperty("monkey.bonanza", "pale\ncomparison");
|
||||
|
||||
Document doc = new ProjectConfigGenerator(config).generateXmlDocument();
|
||||
XMLWriter xmlWriter = new XMLWriter(System.out);
|
||||
xmlWriter.write(doc);
|
||||
xmlWriter.flush();
|
||||
Element configElement = doc.getRootElement();
|
||||
Assert.assertEquals("config", configElement.getName());
|
||||
Assert.assertNotNull(configElement.selectSingleNode("property[1]"));
|
||||
Assert.assertEquals("abc", configElement.selectSingleNode("property[1]/@key").getText());
|
||||
Assert.assertEquals("123", configElement.selectSingleNode("property[1]/@value").getText());
|
||||
|
||||
Assert.assertNotNull(configElement.selectSingleNode("property[2]"));
|
||||
Assert.assertEquals("monkey.bonanza", configElement.selectSingleNode("property[2]/@key").getText());
|
||||
Assert.assertEquals("pale\ncomparison", configElement.selectSingleNode("property[2]/@value").getText());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.rundeck.api.generator;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
/**
|
||||
* ProjectGeneratorTest is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectGeneratorTest {
|
||||
@Test
|
||||
public void generate() {
|
||||
RundeckProject project = new RundeckProject();
|
||||
project.setName("monkey1");
|
||||
|
||||
Document doc = new ProjectGenerator(project).generateXmlDocument();
|
||||
Assert.assertEquals("project", doc.getRootElement().getName());
|
||||
Assert.assertNotNull(doc.selectSingleNode("/project/name"));
|
||||
Assert.assertEquals("monkey1", doc.selectSingleNode("/project/name").getText());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.BaseState;
|
||||
import org.rundeck.api.domain.RundeckWFExecState;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 8:33 AM
|
||||
*/
|
||||
public class BaseStateParserTest {
|
||||
@Test
|
||||
public void testBase1(){
|
||||
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
BaseState baseState = new BaseState();
|
||||
BaseStateParser.parseBaseState(document.selectSingleNode("/result/executionState"), baseState);
|
||||
|
||||
Assert.assertEquals(1390066160000L, baseState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066159000L, baseState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, baseState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, baseState.getExecutionState());
|
||||
}
|
||||
@Test
|
||||
public void testBase2(){
|
||||
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
BaseState baseState = new BaseState();
|
||||
BaseStateParser.parseBaseState(document.selectSingleNode("/result/executionState/steps/step[1]"), baseState);
|
||||
|
||||
Assert.assertEquals(1390066159000L, baseState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, baseState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, baseState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, baseState.getExecutionState());
|
||||
}
|
||||
}
|
|
@ -16,13 +16,17 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckExecution;
|
||||
import org.rundeck.api.domain.RundeckJob;
|
||||
import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
|
||||
import org.rundeck.api.domain.RundeckNodeIdentity;
|
||||
|
||||
/**
|
||||
* Test the {@link ExecutionParser}
|
||||
|
@ -156,4 +160,47 @@ public class ExecutionParserTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseV10Execution() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("execution-result-v10.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckExecution execution = new ExecutionParser("result/executions/execution").parseXmlNode(document);
|
||||
RundeckJob job = execution.getJob();
|
||||
|
||||
Assert.assertNotNull(job);
|
||||
Assert.assertEquals(new Long(146), execution.getId());
|
||||
Assert.assertEquals("http://dignan.local:4440/execution/follow/146", execution.getUrl());
|
||||
Assert.assertEquals(ExecutionStatus.SUCCEEDED, execution.getStatus());
|
||||
Assert.assertEquals("admin", execution.getStartedBy());
|
||||
Assert.assertEquals(new Date(1389894502959L), execution.getStartedAt());
|
||||
Assert.assertEquals(new Date(1389894504561L), execution.getEndedAt());
|
||||
Assert.assertEquals((Long)(1389894504561L- 1389894502959L), execution.getDurationInMillis());
|
||||
Assert.assertEquals(null, execution.getAbortedBy());
|
||||
Assert.assertEquals("fdfd", execution.getProject());
|
||||
|
||||
Assert.assertNotNull(execution.getSuccessfulNodes());
|
||||
Assert.assertEquals(3, execution.getSuccessfulNodes().size());
|
||||
|
||||
HashSet<String> expectedSuccess = new HashSet<String>();
|
||||
expectedSuccess.addAll(Arrays.asList(
|
||||
"node-111.qa.subgroup.mycompany.com",
|
||||
"node-6.qa.subgroup.mycompany.com",
|
||||
"node-14.qa.subgroup.mycompany.com"));
|
||||
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getSuccessfulNodes()) {
|
||||
Assert.assertTrue(expectedSuccess.contains(rundeckNodeIdentity.getName()));
|
||||
}
|
||||
|
||||
Assert.assertNotNull(execution.getFailedNodes());
|
||||
Assert.assertEquals(3, execution.getFailedNodes().size());
|
||||
HashSet<String> expectedFailure = new HashSet<String>();
|
||||
expectedFailure.addAll(Arrays.asList(
|
||||
"node-112.qa.subgroup.mycompany.com",
|
||||
"node-62.qa.subgroup.mycompany.com",
|
||||
"node-12.qa.subgroup.mycompany.com"));
|
||||
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getFailedNodes()) {
|
||||
Assert.assertTrue(expectedFailure.contains(rundeckNodeIdentity.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckExecutionState;
|
||||
import org.rundeck.api.domain.RundeckNodeIdentity;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:42 PM
|
||||
*/
|
||||
public class ExecutionStateParserTest {
|
||||
@Test
|
||||
public void testBasic(){
|
||||
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckExecutionState execution = new ExecutionStateParser("/result/executionState").parseXmlNode
|
||||
(document);
|
||||
|
||||
Assert.assertEquals(149L, execution.getExecutionId());
|
||||
|
||||
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
|
||||
"node-111.qa.subgroup.mycompany.com",
|
||||
"node-14.qa.subgroup.mycompany.com",
|
||||
"node-6.qa.subgroup.mycompany.com"
|
||||
));
|
||||
|
||||
Assert.assertEquals(3, execution.getAllNodes().size());
|
||||
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getAllNodes()) {
|
||||
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
|
||||
}
|
||||
|
||||
Assert.assertEquals(3,execution.getNodeStates().size());
|
||||
for (String s : execution.getNodeStates().keySet()) {
|
||||
Assert.assertTrue(expectedTargetNodes.contains(s));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.WorkflowState;
|
||||
import org.rundeck.api.domain.WorkflowStepContextState;
|
||||
import org.rundeck.api.domain.WorkflowStepState;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 9:57 AM
|
||||
*/
|
||||
public class IndexedWorkflowStepStateParserTest {
|
||||
@Test
|
||||
public void testLookupContextSimple1(){
|
||||
WorkflowState workflowState = new WorkflowState();
|
||||
WorkflowStepState step1 = new WorkflowStepState();
|
||||
workflowState.setSteps(Arrays.asList(step1));
|
||||
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("1", workflowState);
|
||||
Assert.assertEquals(step1,stepState);
|
||||
}
|
||||
@Test
|
||||
public void testLookupContextSimple2(){
|
||||
WorkflowState workflowState = new WorkflowState();
|
||||
WorkflowStepState step1 = new WorkflowStepState();
|
||||
WorkflowStepState step2 = new WorkflowStepState();
|
||||
workflowState.setSteps(Arrays.asList(step1,step2));
|
||||
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("2", workflowState);
|
||||
Assert.assertEquals(step2,stepState);
|
||||
}
|
||||
@Test
|
||||
public void testLookupContextDescend1(){
|
||||
WorkflowState workflowState = new WorkflowState();
|
||||
WorkflowStepState step1 = new WorkflowStepState();
|
||||
WorkflowStepState step2 = new WorkflowStepState();
|
||||
WorkflowState sub1 = new WorkflowState();
|
||||
step2.setSubWorkflow(sub1);
|
||||
workflowState.setSteps(Arrays.asList(step1,step2));
|
||||
|
||||
WorkflowStepState step21 = new WorkflowStepState();
|
||||
sub1.setSteps(Arrays.asList(step21));
|
||||
|
||||
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("2/1", workflowState);
|
||||
Assert.assertEquals(step21,stepState);
|
||||
}
|
||||
@Test
|
||||
public void testParse1() throws DocumentException {
|
||||
WorkflowState workflowState = new WorkflowState();
|
||||
WorkflowStepState step1 = new WorkflowStepState();
|
||||
WorkflowStepState step2 = new WorkflowStepState();
|
||||
WorkflowState sub1 = new WorkflowState();
|
||||
step2.setSubWorkflow(sub1);
|
||||
workflowState.setSteps(Arrays.asList(step1,step2));
|
||||
|
||||
WorkflowStepState step21 = new WorkflowStepState();
|
||||
sub1.setSteps(Arrays.asList(step21));
|
||||
HashMap<String, WorkflowStepContextState> nodeStates = new HashMap<String, WorkflowStepContextState>();
|
||||
WorkflowStepContextState nodeState1 = new WorkflowStepContextState();
|
||||
nodeStates.put("dignan", nodeState1);
|
||||
step21.setNodeStates(nodeStates);
|
||||
|
||||
Document document = DocumentHelper.parseText("<stepctx>2/1</stepctx>");
|
||||
|
||||
WorkflowStepContextState result = new IndexedWorkflowStepStateParser(workflowState,"dignan").parseXmlNode(document);
|
||||
Assert.assertEquals(nodeState1,result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckOutputEntry;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 4:35 PM
|
||||
*/
|
||||
public class OutputEntryParserTest {
|
||||
@Test
|
||||
public void testEntryBasic() {
|
||||
InputStream input = getClass().getResourceAsStream("output1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
OutputEntryParser outputEntryParser = new OutputEntryParser("//entry[1]");
|
||||
|
||||
RundeckOutputEntry rundeckOutputEntry = outputEntryParser.parseXmlNode(document);
|
||||
Assert.assertEquals("hi there", rundeckOutputEntry.getMessage());
|
||||
Assert.assertEquals(null, rundeckOutputEntry.getCommand());
|
||||
Assert.assertEquals(RundeckOutputEntry.RundeckLogLevel.NORMAL, rundeckOutputEntry.getLevel());
|
||||
Assert.assertEquals("node-111.qa.subgroup.mycompany.com", rundeckOutputEntry.getNode());
|
||||
Assert.assertEquals("09:48:23", rundeckOutputEntry.getTime());
|
||||
Assert.assertEquals(new Date(1389894503000L), rundeckOutputEntry.getAbsoluteTime());
|
||||
Assert.assertEquals(null, rundeckOutputEntry.getType());
|
||||
Assert.assertEquals("Raif", rundeckOutputEntry.getUser());
|
||||
Assert.assertNotNull(rundeckOutputEntry.getMetadata());
|
||||
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("stepctx"));
|
||||
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("stepctx"));
|
||||
}
|
||||
@Test
|
||||
public void testEntryState() {
|
||||
InputStream input = getClass().getResourceAsStream("output-state.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
OutputEntryParser outputEntryParser = new OutputEntryParser("//entry[1]");
|
||||
|
||||
RundeckOutputEntry rundeckOutputEntry = outputEntryParser.parseXmlNode(document);
|
||||
Assert.assertEquals(null, rundeckOutputEntry.getMessage());
|
||||
Assert.assertEquals(null, rundeckOutputEntry.getCommand());
|
||||
Assert.assertEquals(RundeckOutputEntry.RundeckLogLevel.NORMAL, rundeckOutputEntry.getLevel());
|
||||
Assert.assertEquals("dignan", rundeckOutputEntry.getNode());
|
||||
Assert.assertEquals("09:48:23", rundeckOutputEntry.getTime());
|
||||
Assert.assertEquals(new Date(1389894503000L), rundeckOutputEntry.getAbsoluteTime());
|
||||
Assert.assertEquals("stepbegin", rundeckOutputEntry.getType());
|
||||
Assert.assertEquals("admin", rundeckOutputEntry.getUser());
|
||||
Assert.assertNotNull(rundeckOutputEntry.getMetadata());
|
||||
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("stepctx"));
|
||||
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("stepctx"));
|
||||
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("step"));
|
||||
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("step"));
|
||||
}
|
||||
}
|
85
src/test/java/org/rundeck/api/parser/OutputParserTest.java
Normal file
85
src/test/java/org/rundeck/api/parser/OutputParserTest.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckExecution;
|
||||
import org.rundeck.api.domain.RundeckOutput;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 4:24 PM
|
||||
*/
|
||||
public class OutputParserTest {
|
||||
@Test
|
||||
public void parseOutputBasic() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("output1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
|
||||
|
||||
Assert.assertEquals(new Long(1602), output.getExecDuration());
|
||||
Assert.assertEquals(new Long(146), output.getExecutionId());
|
||||
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
|
||||
Assert.assertEquals(null, output.getFilterNode());
|
||||
Assert.assertEquals(null, output.getFilterStep());
|
||||
Assert.assertEquals(1409, output.getOffset());
|
||||
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
|
||||
Assert.assertEquals(new Float(99.9), output.getPercentLoaded());
|
||||
Assert.assertEquals(1415, output.getTotalSize());
|
||||
Assert.assertEquals(true, output.isCompleted());
|
||||
Assert.assertEquals(true, output.isExecCompleted());
|
||||
Assert.assertEquals(false, output.isEmpty());
|
||||
Assert.assertEquals(false, output.isHasFailedNodes());
|
||||
Assert.assertEquals(false, output.isUnmodified());
|
||||
Assert.assertEquals(3, output.getLogEntries().size());
|
||||
}
|
||||
@Test
|
||||
public void parseOutputFiltered() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("output-filtered.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
|
||||
|
||||
Assert.assertEquals(new Long(1602), output.getExecDuration());
|
||||
Assert.assertEquals(new Long(146), output.getExecutionId());
|
||||
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
|
||||
Assert.assertEquals("node-111.qa.subgroup.mycompany.com", output.getFilterNode());
|
||||
Assert.assertEquals("1", output.getFilterStep());
|
||||
Assert.assertEquals(1409, output.getOffset());
|
||||
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
|
||||
Assert.assertEquals(new Float(99.9), output.getPercentLoaded());
|
||||
Assert.assertEquals(1415, output.getTotalSize());
|
||||
Assert.assertEquals(true, output.isCompleted());
|
||||
Assert.assertEquals(true, output.isExecCompleted());
|
||||
Assert.assertEquals(false, output.isEmpty());
|
||||
Assert.assertEquals(false, output.isHasFailedNodes());
|
||||
Assert.assertEquals(false, output.isUnmodified());
|
||||
Assert.assertEquals(1, output.getLogEntries().size());
|
||||
}
|
||||
@Test
|
||||
public void parseOutputUnmodified() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("output-unmodified.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
|
||||
|
||||
Assert.assertEquals(new Long(1602), output.getExecDuration());
|
||||
Assert.assertEquals(new Long(146), output.getExecutionId());
|
||||
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
|
||||
Assert.assertEquals(null, output.getFilterNode());
|
||||
Assert.assertEquals(null, output.getFilterStep());
|
||||
Assert.assertEquals(0, output.getOffset());
|
||||
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
|
||||
Assert.assertEquals(null, output.getPercentLoaded());
|
||||
Assert.assertEquals(1415, output.getTotalSize());
|
||||
Assert.assertEquals(true, output.isCompleted());
|
||||
Assert.assertEquals(true, output.isExecCompleted());
|
||||
Assert.assertEquals(false, output.isEmpty());
|
||||
Assert.assertEquals(false, output.isHasFailedNodes());
|
||||
Assert.assertEquals(true, output.isUnmodified());
|
||||
Assert.assertEquals(null, output.getLogEntries());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* ProjectConfigParserTest is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectConfigParserTest {
|
||||
@Test
|
||||
public void parseProject() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("projectv11.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
ProjectConfig config = new ProjectConfigParser("project/config").parseXmlNode(document);
|
||||
|
||||
Assert.assertEquals(10, config.getProperties().size());
|
||||
Assert.assertEquals("ziggy", config.getProperties().get("project.name"));
|
||||
Assert.assertEquals("false", config.getProperties().get("resources.source.1.config.requireFileExists"));
|
||||
Assert.assertEquals("privateKey", config.getProperties().get("project.ssh-authentication"));
|
||||
Assert.assertEquals("jsch-ssh", config.getProperties().get("service.NodeExecutor.default.provider"));
|
||||
Assert.assertEquals("false", config.getProperties().get("resources.source.1.config.includeServerNode"));
|
||||
Assert.assertEquals("false", config.getProperties().get("resources.source.1.config.generateFileAutomatically"));
|
||||
Assert.assertEquals("/var/rundeck/projects/${project.name}/etc/resources.xml",
|
||||
config.getProperties().get("resources.source.1.config.file"));
|
||||
Assert.assertEquals("/var/lib/rundeck/.ssh/id_rsa", config.getProperties().get("project.ssh-keypath"));
|
||||
Assert.assertEquals("jsch-scp", config.getProperties().get("service.FileCopier.default.provider"));
|
||||
Assert.assertEquals("file", config.getProperties().get("resources.source.1.type"));
|
||||
/*
|
||||
<property key='project.name' value='ziggy'/>
|
||||
<property key='resources.source.1.config.requireFileExists' value='false'/>
|
||||
<property key='project.ssh-authentication' value='privateKey'/>
|
||||
<property key='service.NodeExecutor.default.provider' value='jsch-ssh'/>
|
||||
<property key='resources.source.1.config.includeServerNode' value='false'/>
|
||||
<property key='resources.source.1.config.generateFileAutomatically' value='false'/>
|
||||
<property key='resources.source.1.config.file'
|
||||
value='/var/rundeck/projects/${project.name}/etc/resources.xml'/>
|
||||
<property key='project.ssh-keypath' value='/var/lib/rundeck/.ssh/id_rsa'/>
|
||||
<property key='service.FileCopier.default.provider' value='jsch-scp'/>
|
||||
<property key='resources.source.1.type' value='file'/>
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.rundeck.api.domain.ConfigProperty;
|
||||
import org.rundeck.api.domain.ProjectConfig;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-03-07
|
||||
*/
|
||||
public class ProjectConfigPropertyParserTest {
|
||||
@Test
|
||||
public void parseFromProject() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("projectv11.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
ConfigProperty config = new ProjectConfigPropertyParser("project/config/property[1]").parseXmlNode(document);
|
||||
Assert.assertEquals("project.name", config.getKey());
|
||||
Assert.assertEquals("ziggy", config.getValue());
|
||||
/**
|
||||
* <property key='project.name' value='ziggy'/>
|
||||
<property key='resources.source.1.config.requireFileExists' value='false'/>
|
||||
|
||||
*/
|
||||
}
|
||||
@Test
|
||||
public void parseProperty() throws Exception {
|
||||
Document document = ParserHelper.loadDocument(new ByteArrayInputStream(("<property key='project.name' " +
|
||||
"value='ABC' />").getBytes()));
|
||||
|
||||
ConfigProperty config = new ProjectConfigPropertyParser("/property").parseXmlNode(document);
|
||||
Assert.assertEquals("project.name", config.getKey());
|
||||
Assert.assertEquals("ABC", config.getValue());
|
||||
/**
|
||||
* <property key='project.name' value='ziggy'/>
|
||||
<property key='resources.source.1.config.requireFileExists' value='false'/>
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* ProjectParserV11Test is ...
|
||||
*
|
||||
* @author greg
|
||||
* @since 2014-02-27
|
||||
*/
|
||||
public class ProjectParserV11Test {
|
||||
@Test
|
||||
public void parseProject() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("projectv11.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
RundeckProject project = new ProjectParserV11("project").parseXmlNode(document);
|
||||
|
||||
Assert.assertEquals("ziggy", project.getName());
|
||||
Assert.assertNull(project.getDescription());
|
||||
Assert.assertNotNull(project.getProjectConfig());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:47 PM
|
||||
*/
|
||||
public class WorkflowStateParserTest {
|
||||
@Test
|
||||
public void parseBasic(){
|
||||
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
WorkflowState execution = new WorkflowStateParser("result/executionState").parseXmlNode(document);
|
||||
Assert.assertEquals(1390066159000L, execution.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, execution.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, execution.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, execution.getExecutionState());
|
||||
Assert.assertEquals(1, execution.getStepCount());
|
||||
Assert.assertEquals(3, execution.getTargetNodes().size());
|
||||
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
|
||||
"node-111.qa.subgroup.mycompany.com",
|
||||
"node-14.qa.subgroup.mycompany.com",
|
||||
"node-6.qa.subgroup.mycompany.com"
|
||||
));
|
||||
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getTargetNodes()) {
|
||||
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
|
||||
}
|
||||
|
||||
//
|
||||
Assert.assertEquals(1,execution.getSteps().size());
|
||||
WorkflowStepState step1 = execution.getSteps().get(0);
|
||||
}
|
||||
@Test
|
||||
public void parse(){
|
||||
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
WorkflowState execution = new WorkflowStateParser("result/executionState").parseXmlNode(document);
|
||||
Assert.assertEquals(1390066061000L, execution.getStartTime().getTime());
|
||||
Assert.assertEquals(null, execution.getEndTime());
|
||||
Assert.assertEquals(1390066067000L, execution.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.RUNNING, execution.getExecutionState());
|
||||
Assert.assertEquals(2, execution.getStepCount());
|
||||
Assert.assertEquals(1, execution.getTargetNodes().size());
|
||||
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
|
||||
"dignan"
|
||||
));
|
||||
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getTargetNodes()) {
|
||||
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
|
||||
}
|
||||
|
||||
//
|
||||
Assert.assertEquals(2,execution.getSteps().size());
|
||||
WorkflowStepState step1 = execution.getSteps().get(0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package org.rundeck.api.parser;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.dom4j.Document;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 9:00 AM
|
||||
*/
|
||||
public class WorkflowStepStateParserTest {
|
||||
|
||||
@Test
|
||||
public void testParse1() {
|
||||
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
|
||||
("/result/executionState/steps/step[1]"));
|
||||
|
||||
Assert.assertNotNull(stepState);
|
||||
Assert.assertEquals(true, stepState.isNodeStep());
|
||||
Assert.assertEquals(null, stepState.getSubWorkflow());
|
||||
Assert.assertNotNull(stepState.getNodeStates());
|
||||
Assert.assertEquals("1", stepState.getStepContextId());
|
||||
Assert.assertEquals(1, stepState.getStepNum());
|
||||
Assert.assertEquals(1390066159000L, stepState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, stepState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066160000L, stepState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, stepState.getExecutionState());
|
||||
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
|
||||
"node-111.qa.subgroup.mycompany.com",
|
||||
"node-14.qa.subgroup.mycompany.com",
|
||||
"node-6.qa.subgroup.mycompany.com"
|
||||
));
|
||||
|
||||
int i = 0;
|
||||
for (String s : stepState.getNodeStates().keySet()) {
|
||||
Assert.assertTrue(expectedTargetNodes.contains(s));
|
||||
WorkflowStepContextState workflowStepContextState = stepState.getNodeStates().get(s);
|
||||
Assert.assertEquals("1", workflowStepContextState.getStepContextId());
|
||||
Assert.assertEquals(1, workflowStepContextState.getStepNum());
|
||||
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, workflowStepContextState.getExecutionState());
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testParseRunning1() {
|
||||
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
|
||||
("/result/executionState/steps/step[1]"));
|
||||
|
||||
Assert.assertNotNull(stepState);
|
||||
Assert.assertEquals(true, stepState.isNodeStep());
|
||||
Assert.assertEquals(null, stepState.getSubWorkflow());
|
||||
Assert.assertEquals("1", stepState.getStepContextId());
|
||||
Assert.assertEquals(1, stepState.getStepNum());
|
||||
Assert.assertNotNull(stepState.getNodeStates());
|
||||
Assert.assertEquals(1390066061000L, stepState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066066000L, stepState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066061000L, stepState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, stepState.getExecutionState());
|
||||
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
|
||||
"dignan"
|
||||
));
|
||||
|
||||
WorkflowStepContextState workflowStepContextState = stepState.getNodeStates().get("dignan");
|
||||
Assert.assertEquals("1", workflowStepContextState.getStepContextId());
|
||||
Assert.assertEquals(1, workflowStepContextState.getStepNum());
|
||||
Assert.assertEquals(1390066061000L, workflowStepContextState.getStartTime().getTime());
|
||||
Assert.assertEquals(1390066066000L, workflowStepContextState.getEndTime().getTime());
|
||||
Assert.assertEquals(1390066066000L, workflowStepContextState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, workflowStepContextState.getExecutionState());
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testParseRunning2() {
|
||||
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
|
||||
Document document = ParserHelper.loadDocument(input);
|
||||
|
||||
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
|
||||
("/result/executionState/steps/step[2]"));
|
||||
|
||||
Assert.assertNotNull(stepState);
|
||||
Assert.assertEquals(false, stepState.isNodeStep());
|
||||
Assert.assertNotNull(stepState.getSubWorkflow());
|
||||
Assert.assertNull(stepState.getNodeStates());
|
||||
Assert.assertEquals("2", stepState.getStepContextId());
|
||||
Assert.assertEquals(2, stepState.getStepNum());
|
||||
Assert.assertEquals(1390066066000L, stepState.getStartTime().getTime());
|
||||
Assert.assertNull(stepState.getEndTime());
|
||||
Assert.assertEquals(1390066066000L, stepState.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.RUNNING, stepState.getExecutionState());
|
||||
|
||||
|
||||
//sub workflow
|
||||
WorkflowState subWorkflow = stepState.getSubWorkflow();
|
||||
Assert.assertEquals(1,subWorkflow.getSteps().size());
|
||||
Assert.assertEquals(1,subWorkflow.getTargetNodes().size());
|
||||
|
||||
WorkflowStepState stepState1 = subWorkflow.getSteps().get(0);
|
||||
Assert.assertEquals(true, stepState1.isNodeStep());
|
||||
Assert.assertNull(stepState1.getSubWorkflow());
|
||||
Assert.assertNotNull(stepState1.getNodeStates());
|
||||
Assert.assertEquals("2/1", stepState1.getStepContextId());
|
||||
Assert.assertEquals(1, stepState1.getStepNum());
|
||||
Assert.assertEquals(1390066067000L, stepState1.getStartTime().getTime());
|
||||
Assert.assertNull(stepState1.getEndTime());
|
||||
Assert.assertEquals(1390066067000L, stepState1.getUpdateTime().getTime());
|
||||
Assert.assertEquals(RundeckWFExecState.RUNNING, stepState1.getExecutionState());
|
||||
|
||||
}
|
||||
}
|
36
src/test/resources/betamax/tapes/api_token_delete.yaml
Normal file
36
src/test/resources/betamax/tapes/api_token_delete.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
!tape
|
||||
name: api_token_delete
|
||||
interactions:
|
||||
- recorded: 2014-04-04T18:38:18.432Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/11/token/MiquQjELTrEaugpmdgAKs1W3a7xonAwU
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=j0fidhqqsmlt1qmvaawr52a42;Path=/
|
||||
- recorded: 2014-04-04T18:38:18.523Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/token/MiquQjELTrEaugpmdgAKs1W3a7xonAwU
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
X-Rundeck-API-Version: '11'
|
||||
body: "<result error='true' apiversion='11'>\n <error code='api.error.item.doesnotexist'>\n <message>Token does not exist: MiquQjELTrEaugpmdgAKs1W3a7xonAwU</message>\n </error>\n</result>"
|
25
src/test/resources/betamax/tapes/api_token_generate.yaml
Normal file
25
src/test/resources/betamax/tapes/api_token_generate.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
!tape
|
||||
name: api_token_generate
|
||||
interactions:
|
||||
- recorded: 2014-04-04T18:21:07.759Z
|
||||
request:
|
||||
method: POST
|
||||
uri: http://rundeck.local:4440/api/11/tokens/bob
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Length: '0'
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 201
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1gt9t2gch2zff1a0werz1us5wk;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHRva2VuIGlkPSdNaXF1UWpFTFRyRWF1Z3BtZGdBS3MxVzNhN3hvbkF3VScgdXNlcj0nYm9iJyAvPg==
|
24
src/test/resources/betamax/tapes/api_token_get.yaml
Normal file
24
src/test/resources/betamax/tapes/api_token_get.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
!tape
|
||||
name: api_token_get
|
||||
interactions:
|
||||
- recorded: 2014-04-04T18:23:05.986Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/token/MiquQjELTrEaugpmdgAKs1W3a7xonAwU
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1tdpszk6b3v191p0ng2u94rohw;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHRva2VuIGlkPSdNaXF1UWpFTFRyRWF1Z3BtZGdBS3MxVzNhN3hvbkF3VScgdXNlcj0nYm9iJyAvPg==
|
24
src/test/resources/betamax/tapes/api_tokens_list_all.yaml
Normal file
24
src/test/resources/betamax/tapes/api_tokens_list_all.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
!tape
|
||||
name: api_tokens_list_all
|
||||
interactions:
|
||||
- recorded: 2014-04-04T18:32:37.397Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/tokens
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=ixag173yjktz1c5o9yrbe5z5a;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHRva2VucyBjb3VudD0nNCcgYWxsdXNlcnM9J3RydWUnPgogIDx0b2tlbiBpZD0nOERwOW9wMTExRVI2b3BzRFJrZGR2RTg2SzlzRTQ5OXMnIHVzZXI9J2FkbWluJyAvPgogIDx0b2tlbiBpZD0naElOcDVlR3p2WUE5VWVQYlVDaGFLSGQ1TmlSa3dXYngnIHVzZXI9J2JvYicgLz4KICA8dG9rZW4gaWQ9J05hTm53VnpBSEFHODNxT1M3V3R3aDZtamNYVml5V1VWJyB1c2VyPSdib2InIC8+CiAgPHRva2VuIGlkPSdNaXF1UWpFTFRyRWF1Z3BtZGdBS3MxVzNhN3hvbkF3VScgdXNlcj0nYm9iJyAvPgo8L3Rva2Vucz4=
|
24
src/test/resources/betamax/tapes/api_tokens_list_user.yaml
Normal file
24
src/test/resources/betamax/tapes/api_tokens_list_user.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
!tape
|
||||
name: api_tokens_list_user
|
||||
interactions:
|
||||
- recorded: 2014-04-04T18:26:33.394Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/tokens/bob
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=114794elwavo26cx4ugkv7pe7;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHRva2VucyBjb3VudD0nMycgdXNlcj0nYm9iJz4KICA8dG9rZW4gaWQ9J2hJTnA1ZUd6dllBOVVlUGJVQ2hhS0hkNU5pUmt3V2J4JyB1c2VyPSdib2InIC8+CiAgPHRva2VuIGlkPSdOYU5ud1Z6QUhBRzgzcU9TN1d0d2g2bWpjWFZpeVdVVicgdXNlcj0nYm9iJyAvPgogIDx0b2tlbiBpZD0nTWlxdVFqRUxUckVhdWdwbWRnQUtzMVczYTd4b25Bd1UnIHVzZXI9J2JvYicgLz4KPC90b2tlbnM+
|
26
src/test/resources/betamax/tapes/create_projectv11.yaml
Normal file
26
src/test/resources/betamax/tapes/create_projectv11.yaml
Normal file
|
@ -0,0 +1,26 @@
|
|||
!tape
|
||||
name: create_projectv11
|
||||
interactions:
|
||||
- recorded: 2014-02-27T19:45:35.430Z
|
||||
request:
|
||||
method: POST
|
||||
uri: http://rundeck.local:4440/api/11/projects
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Type: application/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
Transfer-Encoding: chunked
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1h2r5l35j4ynqo19dsm6xa2gv;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHByb2plY3QgdXJsPSdodHRwOi8vZGlnbmFuLmxvY2FsOjQ0NDAvYXBpLzExL3Byb2plY3QvbW9ua2V5MSc+CiAgPG5hbWU+bW9ua2V5MTwvbmFtZT4KICA8ZGVzY3JpcHRpb24+PC9kZXNjcmlwdGlvbj4KICA8Y29uZmlnPgogICAgPHByb3BlcnR5IGtleT0ncHJvamVjdC5uYW1lJyB2YWx1ZT0nbW9ua2V5MScgLz4KICAgIDxwcm9wZXJ0eSBrZXk9J3Byb2plY3Quc3NoLWF1dGhlbnRpY2F0aW9uJyB2YWx1ZT0ncHJpdmF0ZUtleScgLz4KICAgIDxwcm9wZXJ0eSBrZXk9J3NlcnZpY2UuTm9kZUV4ZWN1dG9yLmRlZmF1bHQucHJvdmlkZXInIHZhbHVlPSdqc2NoLXNzaCcgLz4KICAgIDxwcm9wZXJ0eSBrZXk9J3Jlc291cmNlcy5zb3VyY2UuMS5jb25maWcuaW5jbHVkZVNlcnZlck5vZGUnIHZhbHVlPSd0cnVlJyAvPgogICAgPHByb3BlcnR5IGtleT0ncmVzb3VyY2VzLnNvdXJjZS4xLmNvbmZpZy5nZW5lcmF0ZUZpbGVBdXRvbWF0aWNhbGx5JyB2YWx1ZT0ndHJ1ZScgLz4KICAgIDxwcm9wZXJ0eSBrZXk9J3Jlc291cmNlcy5zb3VyY2UuMS5jb25maWcuZmlsZScgdmFsdWU9Jy9Vc2Vycy9ncmVnL3J1bmRlY2syZC9wcm9qZWN0cy9tb25rZXkxL2V0Yy9yZXNvdXJjZXMueG1sJyAvPgogICAgPHByb3BlcnR5IGtleT0ncHJvamVjdC5zc2gta2V5cGF0aCcgdmFsdWU9Jy9Vc2Vycy9ncmVnLy5zc2gvaWRfcnNhJyAvPgogICAgPHByb3BlcnR5IGtleT0nc2VydmljZS5GaWxlQ29waWVyLmRlZmF1bHQucHJvdmlkZXInIHZhbHVlPSdqc2NoLXNjcCcgLz4KICAgIDxwcm9wZXJ0eSBrZXk9J3Jlc291cmNlcy5zb3VyY2UuMS50eXBlJyB2YWx1ZT0nZmlsZScgLz4KICA8L2NvbmZpZz4KPC9wcm9qZWN0Pg==
|
|
@ -0,0 +1,23 @@
|
|||
!tape
|
||||
name: delete_all_job_executions_success
|
||||
interactions:
|
||||
- recorded: 2014-11-06T18:03:44.789Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/job/764c1209-68ed-4185-8d43-a739364bf156/executions
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=cqqoff205qus10sz1v3t54rk7;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PGRlbGV0ZUV4ZWN1dGlvbnMgcmVxdWVzdENvdW50PScyJyBhbGxzdWNjZXNzZnVsPSd0cnVlJz4KICA8c3VjY2Vzc2Z1bCBjb3VudD0nMicgLz4KPC9kZWxldGVFeGVjdXRpb25zPg==
|
|
@ -0,0 +1,21 @@
|
|||
!tape
|
||||
name: delete_all_job_executions_unauthorized
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:57:02.905Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/job/764c1209-68ed-4185-8d43-a739364bf156/executions
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 403
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=splzhkd5xunl1noidus2o7im3;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
body: "<result error='true' apiversion='12'>\n <error code='api.error.item.unauthorized'>\n <message>Not authorized for action \"Delete Execution\" for Project test</message>\n </error>\n</result>"
|
|
@ -0,0 +1,21 @@
|
|||
!tape
|
||||
name: delete_execution_failure
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:45:47.952Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/execution/640
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1eynpbisggwsy18ax352yya8k0;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
body: "<result error='true' apiversion='12'>\n <error code='api.error.item.doesnotexist'>\n <message>Execution ID does not exist: 640</message>\n </error>\n</result>"
|
|
@ -0,0 +1,19 @@
|
|||
!tape
|
||||
name: delete_execution_success
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:45:47.749Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/12/execution/643
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1hlysemt7deir1j9r7l6ildg5x;Path=/
|
|
@ -0,0 +1,26 @@
|
|||
!tape
|
||||
name: delete_executions_mixed
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:29:44.266Z
|
||||
request:
|
||||
method: POST
|
||||
uri: http://rundeck.local:4440/api/12/executions/delete
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Type: application/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
Transfer-Encoding: chunked
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=smlj6wcfe4yccemt6bptnmgy;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PGRlbGV0ZUV4ZWN1dGlvbnMgcmVxdWVzdENvdW50PSczJyBhbGxzdWNjZXNzZnVsPSdmYWxzZSc+CiAgPHN1Y2Nlc3NmdWwgY291bnQ9JzEnIC8+CiAgPGZhaWxlZCBjb3VudD0nMic+CiAgICA8ZXhlY3V0aW9uIGlkPScxNjQwJyBtZXNzYWdlPSdFeGVjdXRpb24gTm90IGZvdW5kOiAxNjQwJyAvPgogICAgPGV4ZWN1dGlvbiBpZD0nNjQwJyBtZXNzYWdlPSdFeGVjdXRpb24gTm90IGZvdW5kOiA2NDAnIC8+CiAgPC9mYWlsZWQ+CjwvZGVsZXRlRXhlY3V0aW9ucz4=
|
|
@ -0,0 +1,26 @@
|
|||
!tape
|
||||
name: delete_executions_success
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:24:56.487Z
|
||||
request:
|
||||
method: POST
|
||||
uri: http://rundeck.local:4440/api/12/executions/delete
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Type: application/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
Transfer-Encoding: chunked
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1xueq6cjfrsnxjn43hcfadqyk;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PGRlbGV0ZUV4ZWN1dGlvbnMgcmVxdWVzdENvdW50PScyJyBhbGxzdWNjZXNzZnVsPSd0cnVlJz4KICA8c3VjY2Vzc2Z1bCBjb3VudD0nMicgLz4KPC9kZWxldGVFeGVjdXRpb25zPg==
|
|
@ -0,0 +1,26 @@
|
|||
!tape
|
||||
name: delete_executions_success
|
||||
interactions:
|
||||
- recorded: 2014-11-06T17:15:24.673Z
|
||||
request:
|
||||
method: POST
|
||||
uri: http://rundeck.local:4440/api/12/executions/delete
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Type: application/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
Transfer-Encoding: chunked
|
||||
User-Agent: RunDeck API Java Client 12
|
||||
X-RunDeck-Auth-Token: GG7uj1y6UGahOs7QlmeN2sIwz1Y2j7zI
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1kzmot0r2scpjfxlcpfthh7tz;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PGRlbGV0ZUV4ZWN1dGlvbnMgcmVxdWVzdENvdW50PScyJyBhbGxzdWNjZXNzZnVsPSdmYWxzZSc+CiAgPHN1Y2Nlc3NmdWwgY291bnQ9JzAnIC8+CiAgPGZhaWxlZCBjb3VudD0nMic+CiAgICA8ZXhlY3V0aW9uIGlkPSc2NDEnIG1lc3NhZ2U9J1VuYXV0aG9yaXplZDogRGVsZXRlIGV4ZWN1dGlvbiBpbiBwcm9qZWN0IHRlc3QnIC8+CiAgICA8ZXhlY3V0aW9uIGlkPSc2NDAnIG1lc3NhZ2U9J1VuYXV0aG9yaXplZDogRGVsZXRlIGV4ZWN1dGlvbiBpbiBwcm9qZWN0IHRlc3QnIC8+CiAgPC9mYWlsZWQ+CjwvZGVsZXRlRXhlY3V0aW9ucz4=
|
19
src/test/resources/betamax/tapes/delete_job.yaml
Normal file
19
src/test/resources/betamax/tapes/delete_job.yaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
!tape
|
||||
name: delete_job
|
||||
interactions:
|
||||
- recorded: 2014-11-06T18:14:48.773Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/11/job/api-test-job-run-scheduled
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1hb33nx0a7qv21gyuoqes2pahg;Path=/
|
21
src/test/resources/betamax/tapes/delete_job_not_found.yaml
Normal file
21
src/test/resources/betamax/tapes/delete_job_not_found.yaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
!tape
|
||||
name: delete_job_not_found
|
||||
interactions:
|
||||
- recorded: 2014-11-06T18:21:13.147Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/11/job/does-not-exist
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: 8Dp9op111ER6opsDRkddvE86K9sE499s
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1sxop3bupsrqb1gupbru3vklba;Path=/
|
||||
X-Rundeck-API-Version: '12'
|
||||
body: "<result error='true' apiversion='12'>\n <error code='api.error.item.doesnotexist'>\n <message>Job ID does not exist: does-not-exist</message>\n </error>\n</result>"
|
|
@ -0,0 +1,57 @@
|
|||
!tape
|
||||
name: delete_project_config_keyedv11
|
||||
interactions:
|
||||
- recorded: 2014-03-07T19:59:51.228Z
|
||||
request:
|
||||
method: PUT
|
||||
uri: http://rundeck.local:4440/api/11/project/ABC/config/monkey-burrito
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Content-Type: application/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
Transfer-Encoding: chunked
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=bolnwf54stai1bo049hylrsua;Path=/
|
||||
X-Rundeck-API-Version: '11'
|
||||
X-Rundeck-API-XML-Response-Wrapper: 'false'
|
||||
body: !!binary |-
|
||||
PHByb3BlcnR5IGtleT0nbW9ua2V5LWJ1cnJpdG8nIHZhbHVlPSc3dXAnIC8+
|
||||
- recorded: 2014-03-07T19:59:51.325Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/11/project/ABC/config/monkey-burrito
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
- recorded: 2014-03-07T19:59:51.402Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/project/ABC/config/monkey-burrito
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
X-Rundeck-API-Version: '11'
|
||||
body: "<result error='true' apiversion='11'>\n <error code='api.error.item.doesnotexist'>\n <message>property does not exist: monkey-burrito</message>\n </error>\n</result>"
|
36
src/test/resources/betamax/tapes/delete_projectv11.yaml
Normal file
36
src/test/resources/betamax/tapes/delete_projectv11.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
!tape
|
||||
name: delete_projectv11
|
||||
interactions:
|
||||
- recorded: 2014-03-07T20:34:06.758Z
|
||||
request:
|
||||
method: DELETE
|
||||
uri: http://rundeck.local:4440/api/11/project/delete_me
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 204
|
||||
headers:
|
||||
Content-Type: text/html;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=17vo5m2nghd0e1dcg0hqsuxklu;Path=/
|
||||
- recorded: 2014-03-07T20:34:06.903Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/11/project/delete_me
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 11
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 404
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
X-Rundeck-API-Version: '11'
|
||||
body: "<result error='true' apiversion='11'>\n <error code='api.error.item.doesnotexist'>\n <message>project does not exist: delete_me</message>\n </error>\n</result>"
|
24
src/test/resources/betamax/tapes/execution_output_basic.yaml
Normal file
24
src/test/resources/betamax/tapes/execution_output_basic.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
!tape
|
||||
name: execution_output_basic
|
||||
interactions:
|
||||
- recorded: 2014-01-17T01:12:05.218Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/10/execution/146/output?offset=0&lastmod=0
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 10
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1lnnniwx8tih2ehakkgipuyra;Path=/
|
||||
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
|
||||
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <entries>\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z'\
|
||||
\ log='hi there' level='NORMAL' user='Raif' command='' stepctx='1' node='node-111.qa.subgroup.mycompany.com' />\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com'\
|
||||
\ />\n <entry time='09:48:24' absolute_time='2014-01-16T17:48:24Z' log='hi there' level='NORMAL' user='Carolyn' command='' stepctx='1' node='node-6.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"
|
|
@ -0,0 +1,23 @@
|
|||
!tape
|
||||
name: execution_output_fornode
|
||||
interactions:
|
||||
- recorded: 2014-01-17T01:07:39.379Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/10/execution/146/output/node/node-14.qa.subgroup.mycompany.com?offset=0&lastmod=0
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 10
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=17y6a48eoxo7w4eqjrnba9xzz;Path=/
|
||||
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
|
||||
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <filter nodename='node-14.qa.subgroup.mycompany.com' />\n <entries>\n\
|
||||
\ <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"
|
|
@ -0,0 +1,23 @@
|
|||
!tape
|
||||
name: execution_output_fornodeandstep
|
||||
interactions:
|
||||
- recorded: 2014-01-17T01:21:20.524Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/10/execution/146/output/node/node-14.qa.subgroup.mycompany.com/step/1?offset=0&lastmod=0
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 10
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=1tik7xow5yg5t1avvahzumv6u1;Path=/
|
||||
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
|
||||
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <filter nodename='node-14.qa.subgroup.mycompany.com' stepctx='1' />\n \
|
||||
\ <entries>\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue