Interface APIClient

    • 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.
      • 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 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

        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 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​(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 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​(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
      • getHttpResponse

        com.google.api.client.http.HttpResponse getHttpResponse​(java.lang.String uri,
                                                                Context<?> context)
                                                         throws APIException
        Throws:
        APIException