Package com.testdroid.api
Interface APIClient
- All Known Implementing Classes:
AbstractAPIClient
,APIKeyClient
,DefaultAPIClient
public interface APIClient
- Author:
- Ćukasz Kajda <[email protected]>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls DELETE request to APIfindDevicePropertyInLabelGroup
(String groupName, String labelName) Calls GET request to API.<T extends APIEntity>
TCalls GET request to APIreturn resource for accessing list of devices in Cloud using provided filtersgetDevices
(Context<APIDevice> context) com.google.api.client.http.HttpResponse
getHttpResponse
(String uri, Context<?> context) getLabelGroups
(Context<APILabelGroup> context) me()
Fetch and return me - the authenticated user.<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 APIvoid
setConnectTimeout
(int timeout) Sets establish connection timeout for APIClient requests.void
setRequestTimeout
(int timeout) Sets timeout for read data from established connection for APIClient requests.
-
Method Details
-
setConnectTimeout
void setConnectTimeout(int timeout) Sets establish connection timeout for APIClient requests.- Parameters:
timeout
- timeout is ms. Value 0 means infinite timeout.
-
setRequestTimeout
void setRequestTimeout(int timeout) Sets timeout for read data from established connection for APIClient requests.- Parameters:
timeout
- timeout is ms. Value 0 means infinite timeout.
-
me
Fetch and return me - the authenticated user.- Throws:
APIException
- on invalid username, password or API error.
-
get
Calls GET request to API- 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
- Throws:
APIException
-
get
Calls GET request to API. Used when result expected as stream.- 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
Calls POST request to API- 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
<T extends APIEntity> T postFile(String uri, String contentType, File file, Map<String, String> fileExtraParams, Class<T> type) throws APIExceptionCalls POST request to API- 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
Calls DELETE request to API- Parameters:
uri
- context URI of the resource (without/api/v2
prefix- Throws:
APIException
- on any problem related to API communication
-
getDevices
APIListResource<APIDevice> getDevices()return resource for accessing list of devices in Cloud using provided filters- Returns:
- list resource for accessing all devices matching selected filters, if no filter used returns all devices
-
getDevices
-
getLabelGroups
APIListResource<APILabelGroup> getLabelGroups() -
getLabelGroups
-
findDevicePropertyInLabelGroup
Optional<APIDeviceProperty> findDevicePropertyInLabelGroup(String groupName, String labelName) throws APIException - Throws:
APIException
-
getHttpResponse
com.google.api.client.http.HttpResponse getHttpResponse(String uri, Context<?> context) throws APIException - Throws:
APIException
-