public class JenkinsHttpClient
extends java.lang.Object
| 构造器和说明 |
|---|
JenkinsHttpClient(java.net.URI uri)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(java.net.URI uri,
org.apache.http.impl.client.CloseableHttpClient client)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(java.net.URI uri,
org.apache.http.impl.client.HttpClientBuilder builder)
Create an unauthenticated Jenkins HTTP client
|
JenkinsHttpClient(java.net.URI uri,
java.lang.String username,
java.lang.String password)
Create an authenticated Jenkins HTTP client
|
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
get(java.lang.String path)
Perform a GET request and parse the response and return a simple string
of the content
|
<T extends BaseModel> |
get(java.lang.String path,
java.lang.Class<T> cls)
Perform a GET request and parse the response to the given class
|
java.io.InputStream |
getFile(java.net.URI path)
Perform a GET request and return the response as InputStream
|
java.lang.String |
getJenkinsVersion() |
<T extends BaseModel> |
getQuietly(java.lang.String path,
java.lang.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(java.lang.String path,
java.util.Map<java.lang.String,java.lang.String> data,
boolean crumbFlag)
Perform a POST request using form url encoding.
|
java.lang.String |
post_text(java.lang.String path,
java.lang.String textData,
boolean crumbFlag)
Post a text entity to the given URL using the default content type
|
java.lang.String |
post_text(java.lang.String path,
java.lang.String textData,
org.apache.http.entity.ContentType contentType,
boolean crumbFlag)
Post a text entity to the given URL with the given content type
|
java.lang.String |
post_xml(java.lang.String path,
java.lang.String xml_data)
Perform a POST request of XML (instead of using json mapper) and return a
string rendering of the response entity.
|
java.lang.String |
post_xml(java.lang.String path,
java.lang.String xml_data,
boolean crumbFlag) |
void |
post(java.lang.String path)
Perform POST request that takes no parameters and returns no response
|
void |
post(java.lang.String path,
boolean crumbFlag) |
<R extends BaseModel,D> |
post(java.lang.String path,
D data,
java.lang.Class<R> cls) |
<R extends BaseModel,D> |
post(java.lang.String path,
D data,
java.lang.Class<R> cls,
boolean crumbFlag)
Perform a POST request and parse the response to the given class
|
public JenkinsHttpClient(java.net.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(java.net.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(java.net.URI uri)
uri - Location of the jenkins server (ex. http://localhost:8080)public JenkinsHttpClient(java.net.URI uri,
java.lang.String username,
java.lang.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(java.lang.String path, java.lang.Class<T> cls) throws java.io.IOException
T - type of the responsepath - path to request, can be relative or absolutecls - class of the responsejava.io.IOException - in case of an error.public java.lang.String get(java.lang.String path)
throws java.io.IOException
path - path to request, can be relative or absolutejava.io.IOException - in case of an error.public <T extends BaseModel> T getQuietly(java.lang.String path, java.lang.Class<T> cls)
T - type of the responsepath - path to request, can be relative or absolutecls - class of the responsepublic java.io.InputStream getFile(java.net.URI path)
throws java.io.IOException
path - path to request, can be relative or absolutejava.io.IOException - in case of an error.public <R extends BaseModel,D> R post(java.lang.String path, D data, java.lang.Class<R> cls) throws java.io.IOException
java.io.IOExceptionpublic <R extends BaseModel,D> R post(java.lang.String path, D data, java.lang.Class<R> cls, boolean crumbFlag) throws java.io.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.java.io.IOException - in case of an error.public void post_form(java.lang.String path,
java.util.Map<java.lang.String,java.lang.String> data,
boolean crumbFlag)
throws java.io.IOException
path - path to request, can be relative or absolutedata - data to postcrumbFlag - true / false.java.io.IOException - in case of an error.public java.lang.String post_xml(java.lang.String path,
java.lang.String xml_data)
throws java.io.IOException
path - path to request, can be relative or absolutexml_data - data data to postjava.io.IOException - in case of an error.public java.lang.String post_xml(java.lang.String path,
java.lang.String xml_data,
boolean crumbFlag)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String post_text(java.lang.String path,
java.lang.String textData,
boolean crumbFlag)
throws java.io.IOException
path - The path.textData - data.crumbFlag - true/false.java.io.IOException - in case of an error.public java.lang.String post_text(java.lang.String path,
java.lang.String textData,
org.apache.http.entity.ContentType contentType,
boolean crumbFlag)
throws java.io.IOException
path - The path.textData - The data.contentType - ContentTypecrumbFlag - true or false.java.io.IOException - in case of an error.public void post(java.lang.String path)
throws java.io.IOException
path - path to requestjava.io.IOException - in case of an error.public void post(java.lang.String path,
boolean crumbFlag)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getJenkinsVersion()