Package com.testdroid.api
Class DefaultAPIClient
java.lang.Object
com.testdroid.api.AbstractAPIClient
com.testdroid.api.DefaultAPIClient
- All Implemented Interfaces:
APIClient
- Author:
- Łukasz Kajda <[email protected]>, Slawomir Pawluk <[email protected]>, Krzysztof Fonał <[email protected]>
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected long
static final String
protected String
static final int
static final int
protected String
protected String
protected String
Fields inherited from class com.testdroid.api.AbstractAPIClient
ACCEPT_HEADER, API_URI, apiURL, clientConnectTimeout, clientRequestTimeout, DEVICES_URI, httpTransport, LABEL_GROUPS_URI
-
Constructor Summary
ConstructorDescriptionDefaultAPIClient
(String cloudURL, String username, String password) DefaultAPIClient
(String cloudURL, String username, String password, boolean skipCheckCertificate) DefaultAPIClient
(String cloudURL, String username, String password, org.apache.http.HttpHost proxy, boolean skipCheckCertificate) DefaultAPIClient
(String cloudURL, String username, String password, org.apache.http.HttpHost proxy, String proxyUser, String proxyPassword, boolean skipCheckCertificate) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
void
Calls DELETE request to APICalls GET request to API.<T extends APIEntity>
TCalls GET request to APIprotected com.google.api.client.http.HttpHeaders
protected com.google.api.client.http.HttpRequestFactory
<T extends APIEntity>
TCalls POST request to API<T extends APIEntity>
TpostFile
(String uri, String contentType, File file, Map<String, String> fileExtraParams, Class<T> type) Calls POST request to APIprotected String
Methods inherited from class com.testdroid.api.AbstractAPIClient
buildUrl, deleteOnce, disconnectQuietly, findDevicePropertyInLabelGroup, fixMapParameters, fromJson, fromJson, get, getAPIException, getDevices, getDevices, getHttpResponse, getLabelGroups, getLabelGroups, getOnce, getStream, me, postOnce, setConnectTimeout, setRequestTimeout
-
Field Details
-
HTTP_CONNECT_TIMEOUT
public static final int HTTP_CONNECT_TIMEOUT- See Also:
-
HTTP_READ_TIMEOUT
public static final int HTTP_READ_TIMEOUT- See Also:
-
BITBAR_API_OAUTH2_CLIENT_ID
- See Also:
-
accessToken
-
accessTokenExpireTime
protected long accessTokenExpireTime -
cloudURL
-
password
-
refreshToken
-
username
-
-
Constructor Details
-
DefaultAPIClient
-
DefaultAPIClient
-
DefaultAPIClient
-
DefaultAPIClient
-
-
Method Details
-
getRequestFactory
- Overrides:
getRequestFactory
in classAbstractAPIClient
- Throws:
APIException
- Overriding classes may throw this exception if they execute some API calls
-
acquireAccessToken
- Throws:
APIException
-
refreshAccessToken
- Throws:
APIException
-
get
Description copied from interface:APIClient
Calls GET request to API- Specified by:
get
in interfaceAPIClient
- Overrides:
get
in classAbstractAPIClient
- Type Parameters:
T
- expected result class to be parsed from response- Parameters:
uri
- context URI of the resource (without/api/v2
prefixtype
- expected result class to be parsed from response- Returns:
- object defined as
T
if succesfully returned and parsed - Throws:
APIException
- on any problem related to API communication
-
get
Description copied from interface:APIClient
Calls GET request to API. Used when result expected as stream.- Specified by:
get
in interfaceAPIClient
- Overrides:
get
in classAbstractAPIClient
- Parameters:
uri
- context URI of the resource (without/api/v2
prefix- Returns:
- stream with response
- Throws:
APIException
- on any problem related to API communication
-
post
Description copied from interface:APIClient
Calls POST request to API- Specified by:
post
in interfaceAPIClient
- Overrides:
post
in classAbstractAPIClient
- Type Parameters:
T
- expected result class to be parsed from response- Parameters:
uri
- context URI of the resource (without/api/v2
prefixbody
- body - usually url encoded, to POST to APItype
- expected result class to be parsed from response- Returns:
- object defined as
T
if succesfully returned and parsed - Throws:
APIException
- on any problem related to API communication
-
postFile
public <T extends APIEntity> T postFile(String uri, String contentType, File file, Map<String, String> fileExtraParams, Class<T> type) throws APIExceptionDescription copied from interface:APIClient
Calls POST request to API- Specified by:
postFile
in interfaceAPIClient
- Overrides:
postFile
in classAbstractAPIClient
- Type Parameters:
T
- expected result class to be parsed from response- Parameters:
uri
- context URI of the resource (without/api/v2
prefix)contentType
- content type of uploaded filefile
- file to be uploaded with that requestfileExtraParams
- extra parameters for form-data describing the filetype
- expected result class to be parsed from response- Returns:
- object defined as
T
if successfully returned and parsed - Throws:
APIException
- on any problem related to API communication
-
delete
Description copied from interface:APIClient
Calls DELETE request to API- Specified by:
delete
in interfaceAPIClient
- Overrides:
delete
in classAbstractAPIClient
- Parameters:
uri
- context URI of the resource (without/api/v2
prefix- Throws:
APIException
- on any problem related to API communication
-
getHttpHeaders
protected com.google.api.client.http.HttpHeaders getHttpHeaders()- Specified by:
getHttpHeaders
in classAbstractAPIClient
-