Package manifold.json.rt.api
Class Endpoint
- java.lang.Object
-
- manifold.json.rt.api.Endpoint
-
public class Endpoint extends Object
Represents a URL endpoint with an optional proxy (HTTP, SOCKS, or direct if no proxy is specified). Abstracts HTTP request operations involving common formats such as JSON, XML, YAML, CSV, and plain text. Typically, the methods of theEndpointclass are called indirectly through higher level APIs.
-
-
Constructor Summary
Constructors Constructor Description Endpoint(String urlBase)Endpoint(String urlBase, String proxyAddr, int proxyPort)Makes anHTTPproxied endpoint.Endpoint(String urlBase, String proxyAddr, int proxyPort, Proxy.Type proxyType)Makes a proxied endpoint at the specifiedurlBase.Endpoint(String urlBase, String proxyAddr, Proxy.Type proxyType)Makes an proxied endpoint on port8080.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLConnectionopenConnection()Opens a connection on this endpoint's URL and Proxy.ObjectsendCsvRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to the endpoint with a CSV response.ObjectsendJsonRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to the endpoint with a JSON response.ObjectsendPlainTextRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with a plain text response.ObjectsendXmlRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with an XML response.ObjectsendYamlRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with a YAML response.EndpointwithUrlSuffix(String urlSuffix)Creates a newEndpointwith a base URL consisting of this endpoint's base URL +urlSuffix.
-
-
-
Constructor Detail
-
Endpoint
public Endpoint(String urlBase)
- Parameters:
urlBase- The base URL for the endpoint. Can have name=value arguments.
-
Endpoint
public Endpoint(String urlBase, String proxyAddr, int proxyPort)
Makes anHTTPproxied endpoint.- Parameters:
urlBase- The base URL for the endpoint. Can have name=value arguments.proxyAddr- The address of the proxy server, such as "http://my.proxyserver.com".proxyPort- The port number of the proxy server, typically 8080.
-
Endpoint
public Endpoint(String urlBase, String proxyAddr, Proxy.Type proxyType)
Makes an proxied endpoint on port8080.- Parameters:
urlBase- The base URL for the endpoint. Can have name=value arguments.proxyAddr- The address of the proxy server, such as "http://my.proxyserver.com".proxyType- The proxy type:HTTP or SOCKS. UseEndpoint(String)if there is no proxy server.
-
Endpoint
public Endpoint(String urlBase, String proxyAddr, int proxyPort, Proxy.Type proxyType)
Makes a proxied endpoint at the specifiedurlBase.- Parameters:
urlBase- The base URL for the endpoint. Can have name=value arguments.proxyAddr- The address of the proxy server, such as "http://my.proxyserver.com".proxyPort- The port number of the proxy server, typically 8080.proxyType- The proxy type:HTTP or SOCKS. UseEndpoint(String)if there is no proxy server.
-
-
Method Detail
-
withUrlSuffix
public Endpoint withUrlSuffix(String urlSuffix)
Creates a newEndpointwith a base URL consisting of this endpoint's base URL +urlSuffix.- Parameters:
urlSuffix- Use the suffix to make a new url consisting of this endpoint's base URL +urlSuffix.- Returns:
- A new
Endpointwith a base URL consisting of this endpoint's base URL +urlSuffix.
-
openConnection
public URLConnection openConnection() throws IOException
Opens a connection on this endpoint's URL and Proxy.- Throws:
IOException- See Also:
URL.openConnection(Proxy)
-
sendCsvRequest
public Object sendCsvRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)
Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to the endpoint with a CSV response.- Parameters:
httpMethod- The HTTP method to use: "GET", "POST", "PUT", or "PATCH"jsonValue- A JSON value to send (primitive/boxed type, String, List of JSON values, or Bindings of String/JSON value)- Returns:
- A JSON bindings value parsed from the CSV response.
-
sendJsonRequest
public Object sendJsonRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)
Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to the endpoint with a JSON response.- Parameters:
httpMethod- The HTTP method to use: "GET", "POST", "PUT", or "PATCH"jsonValue- A JSON value to send (primitive/boxed type, String, List of JSON values, or Bindings of String/JSON value)- Returns:
- A JSON value parsed from the JSON response.
-
sendPlainTextRequest
public Object sendPlainTextRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)
Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with a plain text response.- Parameters:
httpMethod- The HTTP method to use: "GET", "POST", "PUT", or "PATCH"jsonValue- A JSON value to send (primitive/boxed type, String, List of JSON values, or Bindings of String/JSON value)- Returns:
- The raw response body as plain text
-
sendXmlRequest
public Object sendXmlRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)
Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with an XML response.- Parameters:
httpMethod- The HTTP method to use: "GET", "POST", "PUT", or "PATCH"jsonValue- A JSON value to send (primitive/boxed type, String, List of JSON values, or Bindings of String/JSON value)- Returns:
- The raw response body as XML
-
sendYamlRequest
public Object sendYamlRequest(String httpMethod, Object jsonValue, Map<String,String> headers, int timeout)
Use HTTP GET, POST, PUT, or PATCH to send JSON bindings to a URL with a YAML response.- Parameters:
httpMethod- The HTTP method to use: "GET", "POST", "PUT", or "PATCH"jsonValue- A JSON value to send (primitive/boxed type, String, List of JSON values, or Bindings of String/JSON value)- Returns:
- The raw response body as YAML
-
-