public class PCloudAPIClient
extends java.lang.Object
Used to produce Call and MultiCall objects to make network requests to the server
MultiCall
,
Call
,
Request
,
Response
,
MultiResponse
,
RequestInterceptor
Modifier and Type | Class and Description |
---|---|
static class |
PCloudAPIClient.Builder
Builds instances of the PCloudAPIClient and allows different properties to be set as needed
|
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.ExecutorService |
callExecutor()
Returns the ExecutorService for this client
|
ConnectionPool |
connectionPool()
Returns the ConnectionPool for this client
|
int |
connectTimeout()
Returns the maximum amount of time a connection should take to establish itself in milliseconds as an int
|
EndpointProvider |
endpointProvider()
Get the EndpointProvider set for this client instance
|
javax.net.ssl.HostnameVerifier |
hostnameVerifier()
Returns the HostnameVerifier for this client
|
java.util.List<RequestInterceptor> |
interceptors()
Returns a List of RequestInterceptor for this client
|
PCloudAPIClient.Builder |
newBuilder()
Returns a new PCloudAPIClient.Builder to construct the PCloudAPIClient
|
MultiCall |
newCall(java.util.Collection<Request> requests)
Produces a new instance of a MultiCall object to make multiple network calls efficiently.
|
MultiCall |
newCall(java.util.Collection<Request> requests,
Endpoint endpoint)
Produces a new instance of a MultiCall object to make multiple network calls efficiently.
|
Call |
newCall(Request request)
Produces a new instance of a Call object to make a network call
|
ApiChannel |
newChannel()
Create a new ApiChannel for a given Endpoint.
|
ApiChannel |
newChannel(Endpoint endpoint)
Create a new ApiChannel for a given Endpoint.
|
static PCloudAPIClient.Builder |
newClient()
Create a new PCloudAPIClient.Builder instance
|
int |
readTimeout()
Returns the read timeout in milliseconds
|
void |
shutdown()
Shuts down the client clearing up resources such as idle connections
|
javax.net.SocketFactory |
socketFactory()
Returns the SocketFactory for of this client
|
javax.net.ssl.SSLSocketFactory |
sslSocketFactory()
Returns the SSLSocketFactory for this client
|
int |
writeTimeout()
Returns the write timeout in milliseconds
|
public Call newCall(Request request)
The returned Call object will send the request to the Endpoint
returned by
Request.endpoint() or if null, it will send to the endpoint returned from this
PCloudAPIClient instance's EndpointProvider at the time of execution.
public MultiCall newCall(java.util.Collection<Request> requests)
The returned MultiCall instance will batch the provided Request objects and will send them over a single connection, reducing the round-trips and response times.
The batched calls will be sent to the Endpoint returned from this PCloudAPIClient instance's EndpointProvider at the time of execution.
public MultiCall newCall(java.util.Collection<Request> requests, Endpoint endpoint)
The returned MultiCall instance will batch the provided Request objects and will send them over a single connection, reducing the round-trips and response times.
The batched calls will be sent to the provided Endpoint.
requests
- A non-null Collection of Requestendpoint
- A target Endpoint for the MultiCalljava.lang.IllegalArgumentException
- on a null Collection,
on an empty Collection,
on a Collection containing null elementspublic ApiChannel newChannel() throws java.io.IOException
Same as calling newChannel(Endpoint) with the endpoint returned by this client's EndpointProvider instance.
java.io.IOException
- on a connection errorApiChannel
,
newChannel(Endpoint)
,
EndpointProvider
public ApiChannel newChannel(Endpoint endpoint) throws java.io.IOException
The call will create and initialize an ApiChannel instance to a given endpoint, or throw an IOException on error.
endpoint
- a target Endpointjava.io.IOException
- on a connection errorApiChannel
public int connectTimeout()
public int writeTimeout()
public int readTimeout()
public javax.net.SocketFactory socketFactory()
public javax.net.ssl.SSLSocketFactory sslSocketFactory()
public javax.net.ssl.HostnameVerifier hostnameVerifier()
public ConnectionPool connectionPool()
public java.util.concurrent.ExecutorService callExecutor()
public java.util.List<RequestInterceptor> interceptors()
public EndpointProvider endpointProvider()
This will return the EndpointProvider instance given in endpointProvider() or EndpointProvider.DEFAULT if none has been set.
public void shutdown()
public PCloudAPIClient.Builder newBuilder()
public static PCloudAPIClient.Builder newClient()
Use this method to start configuring a new PCloudAPIClient instance.