public class GeotabApi extends Object implements Api
Api.EntityDescriptor<E extends Entity,S extends Search>, Api.MethodDescriptor<P extends AuthenticatedParameters,R>, Api.MultiCallBuilder| Modifier and Type | Field and Description |
|---|---|
protected AtomicReference<LoginResult> |
auth |
protected Credentials |
credentials |
static String |
DEFAULT_SERVER |
protected AtomicReference<ServerInvoker> |
invoker |
static String |
PROTOCOL |
protected String |
server |
static String |
THIS_SERVER |
protected int |
timeout |
| Constructor and Description |
|---|
GeotabApi(Credentials credentials)
Create new api instance.
|
GeotabApi(Credentials credentials,
String server,
int timeout)
Create new api instance.
|
GeotabApi(Credentials credentials,
String server,
int timeout,
String servicePath,
org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
Create new api instance.
|
| Modifier and Type | Method and Description |
|---|---|
LoginResult |
authenticate()
Authenticates a user and provides a
LoginResult if successful. |
Api.MultiCallBuilder |
buildMultiCall()
Builds a type-safe API multi-call.
|
protected ServerInvoker |
buildServerInvoker(String url,
Integer timeout,
String servicePath,
org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) |
<O extends BaseResponse<T>,T> |
call(AuthenticatedRequest<?> in,
Class<O> outT)
Makes a custom method API call specifying the response type.
|
Optional<Id> |
callAdd(AuthenticatedRequest<?> in)
Makes an Add call.
|
<T extends Entity> |
callGet(AuthenticatedRequest<?> in,
Class<T> outT)
Makes a Get call.
|
Optional<Integer> |
callGetCountOf(AuthenticatedRequest<?> in)
Makes a GetCountOf call.
|
<T extends Entity> |
callGetFeed(AuthenticatedRequest<?> in,
Class<T> outT)
Makes a GetFeed call.
|
<P extends AuthenticatedParameters,R> |
callMethod(Api.MethodDescriptor<P,R> method,
P params)
Makes a web method call.
|
void |
callRemove(AuthenticatedRequest<?> in)
Makes a Remove call.
|
<T> Optional<T> |
callResult(AuthenticatedRequest<?> in,
Class<T> outT)
Makes a custom method API call specifying the result type.
|
<T> Optional<List<T>> |
callResultList(AuthenticatedRequest<?> in,
Class<T> outT)
Makes a custom method API call specifying the element type of list result type.
|
void |
callSet(AuthenticatedRequest<?> in)
Makes a Set call.
|
void |
close() |
void |
disconnect() |
boolean |
isAuthenticated()
Check if the API is authenticated.
|
<O extends BaseResponse<T>,T> |
multiCall(MultiCallRequest in,
Class<O> outT)
Makes a type-safe API multi-call.
|
<T> Optional<List<T>> |
uniformMultiCall(List<? extends BaseRequest<?>> calls,
Class<T> outT)
Makes a uniform type-safe API multi-call.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcallAdd, callAdd, callGet, callGet, callGet, callGetAll, callGetById, callGetCountOf, callGetCountOf, callGetFeed, callGetFeed, callRemove, callRemove, callSet, callSet, entity, methodpublic static final String THIS_SERVER
public static final String DEFAULT_SERVER
public static final String PROTOCOL
protected final Credentials credentials
protected final String server
protected final int timeout
protected final AtomicReference<LoginResult> auth
protected final AtomicReference<ServerInvoker> invoker
public GeotabApi(Credentials credentials)
credentials - Credentials used to authenticate.public GeotabApi(Credentials credentials, String server, int timeout)
credentials - Credentials used to authenticate.server - Server url without protocol. Example: my.geotab.comtimeout - Request timeoutpublic GeotabApi(Credentials credentials, String server, int timeout, String servicePath, org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
credentials - Credentials used to authenticate.server - Server url without protocol. Example: my.geotab.comtimeout - Request timeoutservicePath - Service path. Default value is: apiv1httpClient - Custom HttpClient in case custom configuration is neededpublic boolean isAuthenticated()
ApiShould be authenticated only after explicit call to Api.authenticate() or any of the callXxx
methods.
isAuthenticated in interface Apipublic LoginResult authenticate()
ApiLoginResult if successful. It contains the Credentials property
that can be used for further API calls. A result of LoginResult.Path = "ThisServer" occurs when the user is found
on the current server. Otherwise, a server name is returned and the client must redirect to this new server name.
Maximum 10 Authentication requests per minute, per user.
authenticate in interface Apipublic <O extends BaseResponse<T>,T> Optional<T> call(AuthenticatedRequest<?> in, Class<O> outT)
ApiApi.callGet(com.geotab.http.request.AuthenticatedRequest<?>, java.lang.Class<T>), Api.callGetFeed(com.geotab.http.request.AuthenticatedRequest<?>, java.lang.Class<T>), Api.callAdd(com.geotab.http.request.AuthenticatedRequest<?>), call{Method}, etc.) instead.public <T> Optional<T> callResult(AuthenticatedRequest<?> in, Class<T> outT)
ApiApi.callGet(com.geotab.http.request.AuthenticatedRequest<?>, java.lang.Class<T>), Api.callGetFeed(com.geotab.http.request.AuthenticatedRequest<?>, java.lang.Class<T>), Api.callAdd(com.geotab.http.request.AuthenticatedRequest<?>), call{Method}, etc.) instead.callResult in interface Apipublic <P extends AuthenticatedParameters,R> Optional<R> callMethod(Api.MethodDescriptor<P,R> method, P params)
ApiWARNING: Experimental API.
callMethod in interface Apipublic <T> Optional<List<T>> callResultList(AuthenticatedRequest<?> in, Class<T> outT)
ApicallResultList in interface Apipublic Optional<Id> callAdd(AuthenticatedRequest<?> in)
Apipublic <T extends Entity> Optional<List<T>> callGet(AuthenticatedRequest<?> in, Class<T> outT)
Apipublic Optional<Integer> callGetCountOf(AuthenticatedRequest<?> in)
ApicallGetCountOf in interface Apipublic <T extends Entity> Optional<FeedResult<T>> callGetFeed(AuthenticatedRequest<?> in, Class<T> outT)
ApicallGetFeed in interface Apipublic void callSet(AuthenticatedRequest<?> in)
Apipublic void callRemove(AuthenticatedRequest<?> in)
ApicallRemove in interface Apipublic <O extends BaseResponse<T>,T> Optional<T> multiCall(MultiCallRequest in, Class<O> outT)
ApiResponse type needs to be constructed based on the multi-call response types expected. The API "result" is going to be an array, where each item is the result of the corresponding call.
public <T> Optional<List<T>> uniformMultiCall(List<? extends BaseRequest<?>> calls, Class<T> outT)
ApiAll requests must return the same type. This method combine all responses sequentially into a single list. E.g. if 3 device search requests are made and each request returns 2 devices a single list with 6 devices is returned.
WARNING: Experimental API.
uniformMultiCall in interface Apicalls - List of requests. All request must have the same result type.outT - The common type of all requests.public Api.MultiCallBuilder buildMultiCall()
ApiApi.MultiCallBuilder.callResult(com.geotab.http.request.AuthenticatedRequest<?>, java.lang.Class<T>) and finalize it
calling Api.MultiCallBuilder.execute(). The builder can not be reused and Api.MultiCallBuilder.execute() is
always the last call.
WARNING: Experimental API.
buildMultiCall in interface Apipublic void disconnect()
public void close()
close in interface Closeableclose in interface AutoCloseableprotected ServerInvoker buildServerInvoker(String url, Integer timeout, String servicePath, org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
Copyright © 2023. All rights reserved.