public class JetAPI extends API implements IJetAPI, IJetAPIAuth
API.REQUEST_TYPE
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_TEST_RESPONSE
The auth test response from jet
|
protected JetConfig |
config
Jet API Configuration
|
client, context, lockHost, maxDownloadSize
Constructor and Description |
---|
JetAPI(IAPIHttpClient client,
JetConfig conf)
Create a new API instance
|
JetAPI(IAPIHttpClient client,
JetConfig conf,
boolean lockHost)
Create a new API instance
|
JetAPI(IAPIHttpClient client,
JetConfig conf,
boolean lockHost,
long maxDownloadSize)
Create a new API instance
|
Modifier and Type | Method and Description |
---|---|
protected IAPIResponse |
executeRequest(org.apache.http.client.methods.HttpUriRequest hr)
Execute a HttpRequest
|
IJetAPIResponse |
get(String url,
Map<String,String> headers)
Perform a get-based request to some endpoint
|
JetHeaderBuilder |
getHeaderBuilder()
Retrieve a HeaderBuilder instance with an Authorization header
|
JetHeaderBuilder |
getJSONHeaderBuilder()
Retrieve a headers map for use with a JSON request
|
JetHeaderBuilder |
getPlainHeaderBuilder()
Retrieve a headers map for use with a plain text request
|
protected List<String> |
jsonArrayToTokenList(javax.json.JsonArray a,
boolean includePath)
Turn a jet api response into a list of tokens
|
boolean |
login()
Attempt to log in to the Jet API, and retrieve a token
|
IJetAPIResponse |
post(String url,
InputStream payload,
long contentLength,
org.apache.http.entity.ContentType contentType,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
IJetAPIResponse |
post(String url,
PostFile file,
Map<String,String> headers)
Perform a post-based request to some endpoint
|
IJetAPIResponse |
post(String url,
String payload,
Map<String,String> headers)
Send arbitrary post data to some endpoint
|
IJetAPIResponse |
put(String url,
InputStream payload,
long contentLength,
org.apache.http.entity.ContentType contentType,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
IJetAPIResponse |
put(String url,
PostFile file,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
IJetAPIResponse |
put(String url,
String payload,
Map<String,String> headers)
Perform a put-based request to some endpoint
|
void |
setErrorHandler(IJetErrorHandler handler) |
public static final String AUTH_TEST_RESPONSE
protected final JetConfig config
public JetAPI(IAPIHttpClient client, JetConfig conf)
client
- The built APIHttpClient instanceconf
- The Jet Configuration objectpublic JetAPI(IAPIHttpClient client, JetConfig conf, boolean lockHost)
client
- The built APIHttpClient instanceconf
- The Jet Configuration objectlockHost
- Toggle locking the host to a domain if http is not present
in the url string.public JetAPI(IAPIHttpClient client, JetConfig conf, boolean lockHost, long maxDownloadSize)
client
- The built APIHttpClient instanceconf
- The Jet Configuration objectlockHost
- Toggle locking the host to a domain if http is not present
in the url string.maxDownloadSize
- Set a maximum download site for the local client.
This is a fixed limit.public void setErrorHandler(IJetErrorHandler handler)
setErrorHandler
in interface IJetAPI
public JetHeaderBuilder getHeaderBuilder()
getHeaderBuilder
in interface IJetAPI
public JetHeaderBuilder getJSONHeaderBuilder()
getJSONHeaderBuilder
in interface IJetAPI
public JetHeaderBuilder getPlainHeaderBuilder()
getPlainHeaderBuilder
in interface IJetAPI
public IJetAPIResponse get(String url, Map<String,String> headers) throws APIException, JetException
get
in interface IJetAPI
get
in interface IApi
get
in class API
url
- The URLheaders
- Extra headers to sendAPIException
- If something goes wrong (like an IOException)JetException
- if jet has some issuepublic IJetAPIResponse post(String url, String payload, Map<String,String> headers) throws APIException, JetException
post
in interface IJetAPI
post
in interface IApi
post
in class API
url
- URLpayload
- Data to sendheaders
- Extra headers to sendAPIException
- if something goes wrongJetException
public IJetAPIResponse post(String url, InputStream payload, long contentLength, org.apache.http.entity.ContentType contentType, Map<String,String> headers) throws APIException
public IJetAPIResponse post(String url, PostFile file, Map<String,String> headers) throws APIException
API
public IJetAPIResponse put(String url, String payload, Map<String,String> headers) throws APIException, JetException
put
in interface IJetAPI
put
in interface IApi
put
in class API
url
- URLpayload
- Payload to sendheaders
- additional headers to sendAPIException
JetException
public IJetAPIResponse put(String url, InputStream payload, long contentLength, org.apache.http.entity.ContentType contentType, Map<String,String> headers) throws APIException, JetException
put
in interface IJetAPI
put
in interface IApi
put
in class API
url
- URLpayload
- Payload to sendheaders
- additional headers to sendcontentLength
- the length of the payloadcontentType
- the type of data in payloadAPIException
JetException
public IJetAPIResponse put(String url, PostFile file, Map<String,String> headers) throws APIException, JetException
API
put
in interface IJetAPI
put
in interface IApi
put
in class API
url
- URLfile
- file to sendheaders
- additional headersAPIException
JetException
public boolean login() throws APIException, JetException, JetAuthException
login
in interface IJetAPIAuth
APIException
- if something goes wrongJetException
- if there are errors in the API response bodyJetAuthException
- if there is a problem with the authentication
data in the configuration object after setting it from the login response.protected IAPIResponse executeRequest(org.apache.http.client.methods.HttpUriRequest hr) throws APIException
executeRequest
in class API
hr
- requestAPIException
- If the request failedCopyright © 2017. All rights reserved.