Class AnalyticsClient


  • public class AnalyticsClient
    extends java.lang.Object
    AnalyticsClient provides the java based language binding to the HTTPS based API of Zoho Analytics.
    • Constructor Summary

      Constructors 
      Constructor Description
      AnalyticsClient​(java.lang.String clientId, java.lang.String clientSecret, java.lang.String refreshToken)
      Creates a new AnalyticsClient instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.io.Closeable... args)  
      BulkAPI getBulkInstance​(long orgId, long workspaceId)
      Creates a new BulkAPI instance.
      int getConnectionTimeout()
      Returns the timeout until a connection is established.
      org.json.JSONObject getDashboards()
      Returns list of all accessible dashboards.
      OrgAPI getOrgInstance​(long orgId)
      Creates a new OrgAPI instance.
      org.json.JSONArray getOrgs()
      Returns list of all accessible organizations.
      org.json.JSONArray getOwnedDashboards()
      Returns list of owned dashboards.
      org.json.JSONArray getOwnedWorkspaces()
      Returns list of owned workspaces.
      int getReadTimeout()
      Returns the read timeout value which will wait for the packet to receive from the server end.
      org.json.JSONArray getRecentViews()
      Returns list of recently accessed views.
      org.json.JSONArray getSharedDashboards()
      Returns list of shared dashboards.
      org.json.JSONArray getSharedWorkspaces()
      Returns list of shared workspaces.
      org.json.JSONObject getViewDetails​(long viewId, org.json.JSONObject config)
      Returns details of the specified view.
      ViewAPI getViewInstance​(long orgId, long workspaceId, long viewId)
      Creates a new ViewAPI instance.
      org.json.JSONObject getWorkspaceDetails​(long workspaceId)
      Returns details of the specified workspace.
      WorkspaceAPI getWorkspaceInstance​(long orgId, long workspaceId)
      Creates a new WorkspaceAPI instance.
      org.json.JSONObject getWorkspaces()
      Returns list of all accessible workspaces.
      org.json.JSONObject importDataInBatches​(java.lang.String endPoint, org.json.JSONObject config, java.util.Map<java.lang.String,​java.lang.String> reqHeaders, java.io.File csvFile, int batchSize, org.json.JSONObject toolConfig)  
      protected org.json.JSONObject sendAPIRequest​(java.lang.String reqMethod, java.lang.String endPoint, org.json.JSONObject config, java.util.Map<java.lang.String,​java.lang.String> reqHeaders)
      Internal method to send API request.
      protected org.json.JSONObject sendBatchImportAPIRequest​(java.lang.String endPoint, java.util.Map<java.lang.String,​java.lang.String> reqHeaders, java.lang.Object dataHandler)
      Internal method to send API request.
      protected org.json.JSONObject sendExportAPIRequest​(java.lang.String endPoint, org.json.JSONObject config, java.util.Map<java.lang.String,​java.lang.String> reqHeaders, java.lang.Object dataHandler)
      Internal method to send API request.
      protected org.json.JSONObject sendImportAPIRequest​(java.lang.String endPoint, org.json.JSONObject config, java.util.Map<java.lang.String,​java.lang.String> reqHeaders, java.lang.Object dataHandler)
      Internal method to send API request.
      void setAccessToken​(java.lang.String accessToken)  
      void setAccountsServerURL​(java.lang.String serverURL)
      Sets the accounts server URL.
      void setAnalyticsServerURL​(java.lang.String serverURL)
      Sets the analytics server URL.
      void setConnectionTimeout​(int timeout)
      Sets the timeout until a connection is established.
      void setHeaders​(java.lang.String key, java.lang.String value)  
      void setProxy​(java.lang.String proxyHost, int proxyPort, java.lang.String proxyUsername, java.lang.String proxyPassword)
      To specify the proxy server details.
      void setReadTimeout​(int timeout)
      Sets the read timeout which will wait for data response from the server end.
      protected void writeLine​(java.lang.Appendable writer, java.lang.String curLine)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnalyticsClient

        public AnalyticsClient​(java.lang.String clientId,
                               java.lang.String clientSecret,
                               java.lang.String refreshToken)
        Creates a new AnalyticsClient instance.
        Parameters:
        clientId - The client ID string that has been obtained during the client registration.
        clientSecret - The client secret string that has been obtained during the client registration.
        refreshToken - The refresh token string that has been obtained through accounts API.
    • Method Detail

      • setAccessToken

        public void setAccessToken​(java.lang.String accessToken)
      • getOrgInstance

        public OrgAPI getOrgInstance​(long orgId)
        Creates a new OrgAPI instance.
        Parameters:
        orgId - The ID of the organization.
        Returns:
        OrgAPI instance.
      • getWorkspaceInstance

        public WorkspaceAPI getWorkspaceInstance​(long orgId,
                                                 long workspaceId)
        Creates a new WorkspaceAPI instance.
        Parameters:
        orgId - The ID of the organization.
        workspaceId - The ID of the workspace.
        Returns:
        WorkspaceAPI instance.
      • getViewInstance

        public ViewAPI getViewInstance​(long orgId,
                                       long workspaceId,
                                       long viewId)
        Creates a new ViewAPI instance.
        Parameters:
        orgId - The ID of the organization.
        workspaceId - The ID of the workspace.
        viewId - The ID of the view.
        Returns:
        ViewAPI instance.
      • getBulkInstance

        public BulkAPI getBulkInstance​(long orgId,
                                       long workspaceId)
        Creates a new BulkAPI instance.
        Parameters:
        orgId - The ID of the organization.
        workspaceId - The ID of the workspace.
        Returns:
        BulkAPI instance.
      • getOrgs

        public org.json.JSONArray getOrgs()
                                   throws ServerException,
                                          ParseException,
                                          java.io.IOException,
                                          org.json.JSONException
        Returns list of all accessible organizations.
        Returns:
        A JSONArray of organizations list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getWorkspaces

        public org.json.JSONObject getWorkspaces()
                                          throws ServerException,
                                                 ParseException,
                                                 java.io.IOException,
                                                 org.json.JSONException
        Returns list of all accessible workspaces.
        Returns:
        A JSONObject of workspaces list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getOwnedWorkspaces

        public org.json.JSONArray getOwnedWorkspaces()
                                              throws ServerException,
                                                     ParseException,
                                                     java.io.IOException,
                                                     org.json.JSONException
        Returns list of owned workspaces.
        Returns:
        A JSONArray of owned workspaces list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getSharedWorkspaces

        public org.json.JSONArray getSharedWorkspaces()
                                               throws ServerException,
                                                      ParseException,
                                                      java.io.IOException,
                                                      org.json.JSONException
        Returns list of shared workspaces.
        Returns:
        A JSONArray of shared workspaces list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getRecentViews

        public org.json.JSONArray getRecentViews()
                                          throws ServerException,
                                                 ParseException,
                                                 java.io.IOException,
                                                 org.json.JSONException
        Returns list of recently accessed views.
        Returns:
        A JSONArray of recent views list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getDashboards

        public org.json.JSONObject getDashboards()
                                          throws ServerException,
                                                 ParseException,
                                                 java.io.IOException,
                                                 org.json.JSONException
        Returns list of all accessible dashboards.
        Returns:
        A JSONObject of dashboards list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getOwnedDashboards

        public org.json.JSONArray getOwnedDashboards()
                                              throws ServerException,
                                                     ParseException,
                                                     java.io.IOException,
                                                     org.json.JSONException
        Returns list of owned dashboards.
        Returns:
        A JSONArray of owned dashboards list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getSharedDashboards

        public org.json.JSONArray getSharedDashboards()
                                               throws ServerException,
                                                      ParseException,
                                                      java.io.IOException,
                                                      org.json.JSONException
        Returns list of shared dashboards.
        Returns:
        A JSONArray of shared dashboards list.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getWorkspaceDetails

        public org.json.JSONObject getWorkspaceDetails​(long workspaceId)
                                                throws ServerException,
                                                       ParseException,
                                                       java.io.IOException,
                                                       org.json.JSONException
        Returns details of the specified workspace.
        Parameters:
        workspaceId - The ID of the workspace.
        Returns:
        A JSONObject of workspace details.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • getViewDetails

        public org.json.JSONObject getViewDetails​(long viewId,
                                                  org.json.JSONObject config)
                                           throws ServerException,
                                                  ParseException,
                                                  java.io.IOException,
                                                  org.json.JSONException
        Returns details of the specified view.
        Parameters:
        viewId - The ID of the view.
        config - Contains any additional control configurations. Can be null.
        Returns:
        A JSONObject of view details.
        Throws:
        ServerException - If the server has received the request but did not process the request, due to some error.
        ParseException - If the server has responded but the client was not able to parse the response.
        java.io.IOException - If any communication related errors like request time out occurs, when trying to contact the service.
        org.json.JSONException - If any errors while processing the JSON data.
      • setAnalyticsServerURL

        public void setAnalyticsServerURL​(java.lang.String serverURL)
        Sets the analytics server URL.
        Parameters:
        serverURL - The server URL.
      • setAccountsServerURL

        public void setAccountsServerURL​(java.lang.String serverURL)
        Sets the accounts server URL.
        Parameters:
        serverURL - The server URL.
      • getConnectionTimeout

        public int getConnectionTimeout()
        Returns the timeout until a connection is established. A value of zero means the timeout is not used. The default value is 5000.
        Returns:
        A int value.
      • setConnectionTimeout

        public void setConnectionTimeout​(int timeout)
        Sets the timeout until a connection is established. A value of zero means the timeout is not used. The default value is 5000.
        Parameters:
        timeout - Contains connection timeout value.
      • getReadTimeout

        public int getReadTimeout()
        Returns the read timeout value which will wait for the packet to receive from the server end. The default value is 0.
        Returns:
        A int value.
      • setReadTimeout

        public void setReadTimeout​(int timeout)
        Sets the read timeout which will wait for data response from the server end. The default value is 0.
        Parameters:
        timeout - Contains read timeout value.
      • setProxy

        public void setProxy​(java.lang.String proxyHost,
                             int proxyPort,
                             java.lang.String proxyUsername,
                             java.lang.String proxyPassword)
        To specify the proxy server details. (When configuring the proxy settings, ensure that the 'Basic' authentication scheme is not disabled by the JDK).
        Parameters:
        proxyHost - The hostname/IP address of the proxy server.
        proxyPort - The proxy server port.
        proxyUsername - The user name for proxy-server authentication.
        proxyPassword - The password for proxy server authentication.
      • sendAPIRequest

        protected org.json.JSONObject sendAPIRequest​(java.lang.String reqMethod,
                                                     java.lang.String endPoint,
                                                     org.json.JSONObject config,
                                                     java.util.Map<java.lang.String,​java.lang.String> reqHeaders)
                                              throws ServerException,
                                                     ParseException,
                                                     java.io.IOException,
                                                     org.json.JSONException
        Internal method to send API request.
        Throws:
        ServerException
        ParseException
        java.io.IOException
        org.json.JSONException
      • sendExportAPIRequest

        protected org.json.JSONObject sendExportAPIRequest​(java.lang.String endPoint,
                                                           org.json.JSONObject config,
                                                           java.util.Map<java.lang.String,​java.lang.String> reqHeaders,
                                                           java.lang.Object dataHandler)
                                                    throws ServerException,
                                                           ParseException,
                                                           java.io.IOException,
                                                           org.json.JSONException
        Internal method to send API request.
        Throws:
        ServerException
        ParseException
        java.io.IOException
        org.json.JSONException
      • sendImportAPIRequest

        protected org.json.JSONObject sendImportAPIRequest​(java.lang.String endPoint,
                                                           org.json.JSONObject config,
                                                           java.util.Map<java.lang.String,​java.lang.String> reqHeaders,
                                                           java.lang.Object dataHandler)
                                                    throws ServerException,
                                                           ParseException,
                                                           java.io.IOException,
                                                           org.json.JSONException
        Internal method to send API request.
        Throws:
        ServerException
        ParseException
        java.io.IOException
        org.json.JSONException
      • sendBatchImportAPIRequest

        protected org.json.JSONObject sendBatchImportAPIRequest​(java.lang.String endPoint,
                                                                java.util.Map<java.lang.String,​java.lang.String> reqHeaders,
                                                                java.lang.Object dataHandler)
                                                         throws ServerException,
                                                                ParseException,
                                                                java.io.IOException,
                                                                org.json.JSONException
        Internal method to send API request.
        Throws:
        ServerException
        ParseException
        java.io.IOException
        org.json.JSONException
      • setHeaders

        public void setHeaders​(java.lang.String key,
                               java.lang.String value)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • importDataInBatches

        public org.json.JSONObject importDataInBatches​(java.lang.String endPoint,
                                                       org.json.JSONObject config,
                                                       java.util.Map<java.lang.String,​java.lang.String> reqHeaders,
                                                       java.io.File csvFile,
                                                       int batchSize,
                                                       org.json.JSONObject toolConfig)
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writeLine

        protected void writeLine​(java.lang.Appendable writer,
                                 java.lang.String curLine)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public static void close​(java.io.Closeable... args)