Interface APIClient

All Known Implementing Classes:
AbstractAPIClient, APIKeyClient, DefaultAPIClient

public interface APIClient
Author:
Ɓukasz Kajda <[email protected]>
  • 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

      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(String uri, 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 prefix
      type - 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(String uri, Context<T> context) throws APIException
      Throws:
      APIException
    • get

      InputStream get(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(String uri, Object body, 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
      body - body - usually url encoded, to POST to API
      type - 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 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 file
      file - file to be uploaded with that request
      fileExtraParams - extra parameters for form-data describing the file
      type - 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(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

    • 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