public class JenkinsHttpClient extends Object
| Constructor and Description |
|---|
JenkinsHttpClient(URI uri)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(URI uri,
org.apache.http.impl.client.CloseableHttpClient client)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(URI uri,
org.apache.http.impl.client.HttpClientBuilder builder)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(URI uri,
String username,
String password)
Create an authenticated Jenkins HTTP client
|
| Modifier and Type | Method and Description |
|---|---|
protected static org.apache.http.impl.client.HttpClientBuilder |
addAuthentication(org.apache.http.impl.client.HttpClientBuilder builder,
URI uri,
String username,
String password) |
String |
get(String path)
Perform a GET request and parse the response and return a simple string
of the content
|
<T extends BaseModel> |
get(String path,
Class<T> cls)
Perform a GET request and parse the response to the given class
|
InputStream |
getFile(URI path)
Perform a GET request and return the response as InputStream
|
String |
getJenkinsVersion() |
protected org.apache.http.protocol.HttpContext |
getLocalContext() |
<T extends BaseModel> |
getQuietly(String path,
Class<T> cls)
Perform a GET request and parse the response to the given class, logging
any IOException that is thrown rather than propagating it.
|
void |
post_form(String path,
Map<String,String> data,
boolean crumbFlag)
Perform a POST request using form url encoding.
|
String |
post_text(String path,
String textData,
boolean crumbFlag)
Post a text entity to the given URL using the default content type
|
String |
post_text(String path,
String textData,
org.apache.http.entity.ContentType contentType,
boolean crumbFlag)
Post a text entity to the given URL with the given content type
|
String |
post_xml(String path,
String xml_data)
Perform a POST request of XML (instead of using json mapper) and return a
string rendering of the response entity.
|
String |
post_xml(String path,
String xml_data,
boolean crumbFlag) |
void |
post(String path)
Perform POST request that takes no parameters and returns no response
|
void |
post(String path,
boolean crumbFlag) |
<R extends BaseModel,D> |
post(String path,
D data,
Class<R> cls) |
<R extends BaseModel,D> |
post(String path,
D data,
Class<R> cls,
boolean crumbFlag)
Perform a POST request and parse the response to the given class
|
protected void |
setLocalContext(org.apache.http.protocol.HttpContext localContext) |
public JenkinsHttpClient(URI uri, org.apache.http.impl.client.CloseableHttpClient client)
uri - Location of the jenkins server (ex. http://localhost:8080)client - Configured CloseableHttpClient to be usedpublic JenkinsHttpClient(URI uri, org.apache.http.impl.client.HttpClientBuilder builder)
uri - Location of the jenkins server (ex. http://localhost:8080)builder - Configured HttpClientBuilder to be usedpublic JenkinsHttpClient(URI uri)
uri - Location of the jenkins server (ex. http://localhost:8080)public JenkinsHttpClient(URI uri, String username, String password)
uri - Location of the jenkins server (ex. http://localhost:8080)username - Username to use when connectingpassword - Password or auth token to use when connectingpublic <T extends BaseModel> T get(String path, Class<T> cls) throws IOException
T - type of the responsepath - path to request, can be relative or absolutecls - class of the responseIOException - in case of an error.public String get(String path) throws IOException
path - path to request, can be relative or absoluteIOException - in case of an error.public <T extends BaseModel> T getQuietly(String path, Class<T> cls)
T - type of the responsepath - path to request, can be relative or absolutecls - class of the responsepublic InputStream getFile(URI path) throws IOException
path - path to request, can be relative or absoluteIOException - in case of an error.public <R extends BaseModel,D> R post(String path, D data, Class<R> cls) throws IOException
IOExceptionpublic <R extends BaseModel,D> R post(String path, D data, Class<R> cls, boolean crumbFlag) throws IOException
R - type of the responseD - type of the datapath - path to request, can be relative or absolutedata - data to postcls - class of the responsecrumbFlag - true / false.IOException - in case of an error.public void post_form(String path, Map<String,String> data, boolean crumbFlag) throws IOException
path - path to request, can be relative or absolutedata - data to postcrumbFlag - true / false.IOException - in case of an error.public String post_xml(String path, String xml_data) throws IOException
path - path to request, can be relative or absolutexml_data - data data to postIOException - in case of an error.public String post_xml(String path, String xml_data, boolean crumbFlag) throws IOException
IOExceptionpublic String post_text(String path, String textData, boolean crumbFlag) throws IOException
path - The path.textData - data.crumbFlag - true/false.IOException - in case of an error.public String post_text(String path, String textData, org.apache.http.entity.ContentType contentType, boolean crumbFlag) throws IOException
path - The path.textData - The data.contentType - ContentTypecrumbFlag - true or false.IOException - in case of an error.public void post(String path) throws IOException
path - path to requestIOException - in case of an error.public void post(String path, boolean crumbFlag) throws IOException
IOExceptionpublic String getJenkinsVersion()
protected static org.apache.http.impl.client.HttpClientBuilder addAuthentication(org.apache.http.impl.client.HttpClientBuilder builder,
URI uri,
String username,
String password)
protected org.apache.http.protocol.HttpContext getLocalContext()
protected void setLocalContext(org.apache.http.protocol.HttpContext localContext)
Copyright © 2016. All rights reserved.