public class RestClient extends Object
| Constructor and Description |
|---|
RestClient(org.apache.http.client.HttpClient httpclient,
ICredentials creds,
URI uri)
Creates an authenticated REST client instance with a URI.
|
RestClient(org.apache.http.client.HttpClient httpclient,
URI uri)
Creates a REST client instance with a URI.
|
| Modifier and Type | Method and Description |
|---|---|
URI |
buildURI(String path)
Build a URI from a path.
|
URI |
buildURI(String path,
Map<String,String> params)
Build a URI from a path and query parmeters.
|
net.sf.json.JSON |
delete(String path)
Executes an HTTP DELETE with the given path.
|
net.sf.json.JSON |
delete(URI uri)
Executes an HTTP DELETE with the given URI.
|
net.sf.json.JSON |
get(String path)
Executes an HTTP GET with the given path.
|
net.sf.json.JSON |
get(String path,
Map<String,String> params)
Executes an HTTP GET with the given path.
|
net.sf.json.JSON |
get(URI uri)
Executes an HTTP GET with the given URI.
|
org.apache.http.client.HttpClient |
getHttpClient()
Exposes the http client.
|
net.sf.json.JSON |
post(String path)
Executes an HTTP POST with the given path.
|
net.sf.json.JSON |
post(String path,
File file)
Executes an HTTP POST with the given path and file payload.
|
net.sf.json.JSON |
post(String path,
Issue.NewAttachment... attachments)
Executes an HTTP POST with the given path and file payloads.
|
net.sf.json.JSON |
post(String path,
net.sf.json.JSON payload)
Executes an HTTP POST with the given path and payload.
|
net.sf.json.JSON |
post(URI uri,
net.sf.json.JSON payload)
Executes an HTTP POST with the given URI and payload.
|
net.sf.json.JSON |
post(URI uri,
String payload)
Executes an HTTP POST with the given URI and payload.
|
net.sf.json.JSON |
put(String path,
net.sf.json.JSON payload)
Executes an HTTP PUT with the given path and payload.
|
net.sf.json.JSON |
put(URI uri,
net.sf.json.JSON payload)
Executes an HTTP PUT with the given URI and payload.
|
public RestClient(org.apache.http.client.HttpClient httpclient,
URI uri)
httpclient - Underlying HTTP client to useuri - Base URI of the remote REST servicepublic RestClient(org.apache.http.client.HttpClient httpclient,
ICredentials creds,
URI uri)
httpclient - Underlying HTTP client to usecreds - Credentials to send with each requesturi - Base URI of the remote REST servicepublic URI buildURI(String path) throws URISyntaxException
path - Path to append to the base URIURISyntaxException - when the path is invalidpublic URI buildURI(String path, Map<String,String> params) throws URISyntaxException
path - Path to append to the base URIparams - Map of key value pairsURISyntaxException - when the path is invalidpublic net.sf.json.JSON delete(URI uri) throws RestException, IOException
uri - Full URI of the remote endpointRestException - when an HTTP-level error occursIOException - when an error reading the response occurspublic net.sf.json.JSON delete(String path) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic net.sf.json.JSON get(URI uri) throws RestException, IOException
uri - Full URI of the remote endpointRestException - when an HTTP-level error occursIOException - when an error reading the response occurspublic net.sf.json.JSON get(String path, Map<String,String> params) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorparams - Map of key value pairsRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic net.sf.json.JSON get(String path) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic net.sf.json.JSON post(URI uri, net.sf.json.JSON payload) throws RestException, IOException
uri - Full URI of the remote endpointpayload - JSON-encoded data to send to the remote serviceRestException - when an HTTP-level error occursIOException - when an error reading the response occurspublic net.sf.json.JSON post(URI uri, String payload) throws RestException, IOException
uri - Full URI of the remote endpointpayload - Raw string to send to the remote serviceRestException - when an HTTP-level error occursIOException - when an error reading the response occurshttps://jira.atlassian.com/browse/JRA-29304public net.sf.json.JSON post(String path, net.sf.json.JSON payload) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorpayload - JSON-encoded data to send to the remote serviceRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic net.sf.json.JSON post(String path) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic net.sf.json.JSON post(String path, File file) throws RestException, IOException, URISyntaxException
path - Full URI of the remote endpointfile - java.io.FileURISyntaxExceptionIOExceptionRestExceptionpublic net.sf.json.JSON post(String path, Issue.NewAttachment... attachments) throws RestException, IOException, URISyntaxException
path - Full URI of the remote endpointattachments - the name of the attachmentURISyntaxExceptionIOExceptionRestExceptionpublic net.sf.json.JSON put(URI uri, net.sf.json.JSON payload) throws RestException, IOException
uri - Full URI of the remote endpointpayload - JSON-encoded data to send to the remote serviceRestException - when an HTTP-level error occursIOException - when an error reading the response occurspublic net.sf.json.JSON put(String path, net.sf.json.JSON payload) throws RestException, IOException, URISyntaxException
path - Path to be appended to the URI supplied in the construtorpayload - JSON-encoded data to send to the remote serviceRestException - when an HTTP-level error occursIOException - when an error reading the response occursURISyntaxException - when an error occurred appending the path to the URIpublic org.apache.http.client.HttpClient getHttpClient()
Copyright © 2022. All rights reserved.