Class CogniteClient

    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
    • Constructor Detail

      • CogniteClient

        public CogniteClient()
    • Method Detail

      • create

        @Deprecated
        public static CogniteClient create()
                                    throws Exception
        Deprecated.
        Returns a CogniteClient using an API key from the system's environment variables (COGNITE_API_KEY) and using default settings.
        Returns:
        the client object.
        Throws:
        Exception - if the api key cannot be read from the system environment.
      • ofKey

        public static CogniteClient ofKey​(String apiKey)
        Returns a CogniteClient using the provided API key for authentication.
        Parameters:
        apiKey - The Cognite Data Fusion API key to use for authentication.
        Returns:
        the client object with default configuration.
      • ofToken

        public static CogniteClient ofToken​(Supplier<String> tokenSupplier)
        Returns a CogniteClient using the provided supplier (function) to provide a bearer token for authorization. If your application handles the authentication flow itself, you can pass a Supplier to this constructor. The supplier will be called for each api request and the provided token will be added as a bearer token to the request header.
        Parameters:
        tokenSupplier - A Supplier (functional interface) producing a valid access token when called.
        Returns:
        the client object with default configuration.
      • ofClientCredentials

        public static CogniteClient ofClientCredentials​(String clientId,
                                                        String clientSecret,
                                                        URL tokenUrl)
        Returns a CogniteClient using client credentials for authentication. Client credentials is the preferred authentication pattern for services / machine to machine communication for Openid Connect (and Oauth) compatible identity providers.
        Parameters:
        clientId - The client id to use for authentication.
        clientSecret - The client secret to use for authentication.
        tokenUrl - The URL to call for obtaining the access token.
        Returns:
        the client object with default configuration.
      • toBuilder

        protected abstract com.cognite.client.CogniteClient.Builder toBuilder()
      • getProject

        @Nullable
        protected abstract String getProject()
      • getClientId

        @Nullable
        protected abstract String getClientId()
      • getClientSecret

        @Nullable
        protected abstract String getClientSecret()
      • getTokenUrl

        @Nullable
        protected abstract URL getTokenUrl()
      • getApiKey

        @Nullable
        protected abstract String getApiKey()
      • getTokenSupplier

        @Nullable
        protected abstract Supplier<String> getTokenSupplier()
      • getBaseUrl

        protected abstract String getBaseUrl()
      • getClientConfig

        public abstract ClientConfig getClientConfig()
      • getHttpClient

        public abstract okhttp3.OkHttpClient getHttpClient()
      • withProject

        public CogniteClient withProject​(String project)
        Returns a CogniteClient using the specified Cognite Data Fusion project / tenant.
        Parameters:
        project - The project / tenant to use for interacting with Cognite Data Fusion.
        Returns:
        the client object with the project / tenant key set.
      • withBaseUrl

        public CogniteClient withBaseUrl​(String baseUrl)
        Returns a CogniteClient using the specified base URL for issuing API requests. The base URL must follow the format https://<my-host>.cognitedata.com. The default base URL is https://api.cognitedata.com
        Parameters:
        baseUrl - The CDF api base URL
        Returns:
        the client object with the base URL set.
      • withClientConfig

        public CogniteClient withClientConfig​(ClientConfig config)
        Returns a CogniteClient using the specified configuration settings.
        Parameters:
        config - The ClientConfig hosting the client configuration setting.
        Returns:
        the client object with the config applied.
      • enableHttp

        public CogniteClient enableHttp​(boolean enable)
        Enable (or disable) support for http. Set to true to enable support for http calls. Set to false to disable support for http (then only https will be possible). The default setting is disabled. I.e. only https calls are allowed.
        Parameters:
        enable - Set to true to enable support for http calls. Set to false to disable support for http.
        Returns:
        the client object with the config applied.
      • assets

        public Assets assets()
        Returns Assets representing the Cognite assets api endpoint.
        Returns:
        The assets api object.
      • timeseries

        public Timeseries timeseries()
        Returns Timeseries representing the Cognite timeseries api endpoint.
        Returns:
        The timeseries api object.
      • events

        public Events events()
        Returns Events representing the Cognite events api endpoint.
        Returns:
        The events api object.
      • files

        public Files files()
        Returns Files representing the Cognite files api endpoints.
        Returns:
        The labels api endpoint.
      • relationships

        public Relationships relationships()
        Returns Relationships representing the Cognite relationships api endpoint.
        Returns:
        The relationships api object.
      • sequences

        public Sequences sequences()
        Returns Sequences representing the Cognite sequences api endpoint.
        Returns:
        The sequences api object.
      • raw

        public Raw raw()
        Returns Raw representing the Cognite Raw service.
        Returns:
        The raw api object.
      • labels

        public Labels labels()
        Returns Labels representing the Cognite labels api endpoints.
        Returns:
        The labels api endpoint.
      • datasets

        public Datasets datasets()
        Returns Datasets representing the Cognite dats sets api endpoint.
        Returns:
        The data sets api object.
      • securityCategories

        public SecurityCategories securityCategories()
        Returns SecurityCategories representing the Cognite labels api endpoints.
        Returns:
        The security categories api endpoint.
      • contextualization

        public Contextualization contextualization()
        Returns Contextualization representing the Cognite contextualization api endpoints.
        Returns:
        The contextualization api endpoint.
      • experimental

        public Experimental experimental()
        Returns Experimental representing experimental (non-released) api endpoints.
        Returns:
        The Experimental api endpoints.
      • getConnectorService

        protected ConnectorServiceV1 getConnectorService()
        Returns the services layer mirroring the Cognite Data Fusion API.
        Returns:
      • buildAuthConfig

        protected AuthConfig buildAuthConfig()
                                      throws Exception
        Returns a auth info for api requests
        Returns:
        project config with auth info populated
        Throws:
        Exception