Package com.testdroid.api
Interface APIClient
-
- All Known Implementing Classes:
AbstractAPIClient
,APIKeyClient
,DefaultAPIClient
public interface APIClient
- Author:
- Ćukasz Kajda
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
delete(java.lang.String uri)
Calls DELETE request to APIjava.util.Optional<APIDeviceProperty>
findDevicePropertyInLabelGroup(java.lang.String groupName, java.lang.String labelName)
java.io.InputStream
get(java.lang.String uri)
Calls GET request to API.<T extends APIEntity>
APIList<T>get(java.lang.String uri, Context<T> context)
<T extends APIEntity>
Tget(java.lang.String uri, java.lang.Class<T> type)
Calls GET request to APIAPIListResource<APIDevice>
getDevices()
return resource for accessing list of devices in Cloud using provided filtersAPIListResource<APIDevice>
getDevices(Context<APIDevice> context)
com.google.api.client.http.HttpResponse
getHttpResponse(java.lang.String uri, Context<?> context)
APIListResource<APILabelGroup>
getLabelGroups()
APIListResource<APILabelGroup>
getLabelGroups(Context<APILabelGroup> context)
APIUser
me()
Fetch and return me - the authenticated user.<T extends APIEntity>
Tpost(java.lang.String uri, java.lang.Object body, java.lang.Class<T> type)
Calls POST request to API<T extends APIEntity>
TpostFile(java.lang.String uri, java.lang.String contentType, java.io.File file, java.util.Map<java.lang.String,java.lang.String> fileExtraParams, java.lang.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 Detail
-
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
APIUser me() throws APIException
Fetch and return me - the authenticated user.- Throws:
APIException
- on invalid username, password or API error.
-
get
<T extends APIEntity> T get(java.lang.String uri, java.lang.Class<T> type) throws APIException
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
<T extends APIEntity> APIList<T> get(java.lang.String uri, Context<T> context) throws APIException
- Throws:
APIException
-
get
java.io.InputStream get(java.lang.String uri) throws APIException
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
<T extends APIEntity> T post(java.lang.String uri, java.lang.Object body, java.lang.Class<T> type) throws APIException
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(java.lang.String uri, java.lang.String contentType, java.io.File file, java.util.Map<java.lang.String,java.lang.String> fileExtraParams, java.lang.Class<T> type) throws APIException
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
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
void delete(java.lang.String uri) throws APIException
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
APIListResource<APIDevice> getDevices(Context<APIDevice> context)
-
getLabelGroups
APIListResource<APILabelGroup> getLabelGroups()
-
getLabelGroups
APIListResource<APILabelGroup> getLabelGroups(Context<APILabelGroup> context)
-
findDevicePropertyInLabelGroup
java.util.Optional<APIDeviceProperty> findDevicePropertyInLabelGroup(java.lang.String groupName, java.lang.String labelName) throws APIException
- Throws:
APIException
-
getHttpResponse
com.google.api.client.http.HttpResponse getHttpResponse(java.lang.String uri, Context<?> context) throws APIException
- Throws:
APIException
-
-