Package com.cognite.client
Class CogniteClient
- java.lang.Object
-
- com.cognite.client.CogniteClient
-
- All Implemented Interfaces:
Serializable
public abstract class CogniteClient extends Object implements Serializable
This class represents the main entry point for interacting with this SDK (and Cognite Data Fusion). All services are exposed via this object.- See Also:
- Cognite API v1 specification, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CogniteClient.AuthType
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description CogniteClient()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Assets
assets()
ReturnsAssets
representing the Cognite assets api endpoint.protected AuthConfig
buildAuthConfig()
Returns a auth info for api requestsContextualization
contextualization()
ReturnsContextualization
representing the Cognite contextualization api endpoints.static CogniteClient
create()
Deprecated.Datasets
datasets()
ReturnsDatasets
representing the Cognite dats sets api endpoint.CogniteClient
enableHttp(boolean enable)
Enable (or disable) support for http.Events
events()
ReturnsEvents
representing the Cognite events api endpoint.Experimental
experimental()
ReturnsExperimental
representing experimental (non-released) api endpoints.Files
files()
ReturnsFiles
representing the Cognite files api endpoints.protected abstract String
getApiKey()
protected abstract CogniteClient.AuthType
getAuthType()
protected abstract String
getBaseUrl()
abstract ClientConfig
getClientConfig()
protected abstract String
getClientId()
protected abstract String
getClientSecret()
protected ConnectorServiceV1
getConnectorService()
Returns the services layer mirroring the Cognite Data Fusion API.ExecutorService
getExecutorService()
abstract okhttp3.OkHttpClient
getHttpClient()
protected abstract String
getProject()
protected abstract Supplier<String>
getTokenSupplier()
protected abstract URL
getTokenUrl()
Labels
labels()
ReturnsLabels
representing the Cognite labels api endpoints.static CogniteClient
ofClientCredentials(String clientId, String clientSecret, URL tokenUrl)
Returns aCogniteClient
using client credentials for authentication.static CogniteClient
ofKey(String apiKey)
Returns aCogniteClient
using the provided API key for authentication.static CogniteClient
ofToken(Supplier<String> tokenSupplier)
Returns aCogniteClient
using the provided supplier (function) to provide a bearer token for authorization.Raw
raw()
ReturnsRaw
representing the Cognite Raw service.Relationships
relationships()
ReturnsRelationships
representing the Cognite relationships api endpoint.SecurityCategories
securityCategories()
ReturnsSecurityCategories
representing the Cognite labels api endpoints.Sequences
sequences()
ReturnsSequences
representing the Cognite sequences api endpoint.Timeseries
timeseries()
ReturnsTimeseries
representing the Cognite timeseries api endpoint.protected abstract com.cognite.client.CogniteClient.Builder
toBuilder()
CogniteClient
withBaseUrl(String baseUrl)
Returns aCogniteClient
using the specified base URL for issuing API requests.CogniteClient
withClientConfig(ClientConfig config)
Returns aCogniteClient
using the specified configuration settings.CogniteClient
withProject(String project)
Returns aCogniteClient
using the specified Cognite Data Fusion project / tenant.
-
-
-
Method Detail
-
create
@Deprecated public static CogniteClient create() throws Exception
Deprecated.Returns aCogniteClient
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 aCogniteClient
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 aCogniteClient
using the provided supplier (function) to provide a bearer token for authorization. If your application handles the authentication flow itself, you can pass aSupplier
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 aCogniteClient
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()
-
getAuthType
protected abstract CogniteClient.AuthType getAuthType()
-
getBaseUrl
protected abstract String getBaseUrl()
-
getClientConfig
public abstract ClientConfig getClientConfig()
-
getHttpClient
public abstract okhttp3.OkHttpClient getHttpClient()
-
getExecutorService
public ExecutorService getExecutorService()
-
withProject
public CogniteClient withProject(String project)
Returns aCogniteClient
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 aCogniteClient
using the specified base URL for issuing API requests. The base URL must follow the formathttps://<my-host>.cognitedata.com
. The default base URL ishttps://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 aCogniteClient
using the specified configuration settings.- Parameters:
config
- TheClientConfig
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 totrue
to enable support for http calls. Set tofalse
to disable support for http (then only https will be possible). The default setting isdisabled
. I.e. only https calls are allowed.- Parameters:
enable
- Set totrue
to enable support for http calls. Set tofalse
to disable support for http.- Returns:
- the client object with the config applied.
-
assets
public Assets assets()
ReturnsAssets
representing the Cognite assets api endpoint.- Returns:
- The assets api object.
-
timeseries
public Timeseries timeseries()
ReturnsTimeseries
representing the Cognite timeseries api endpoint.- Returns:
- The timeseries api object.
-
events
public Events events()
ReturnsEvents
representing the Cognite events api endpoint.- Returns:
- The events api object.
-
files
public Files files()
ReturnsFiles
representing the Cognite files api endpoints.- Returns:
- The labels api endpoint.
-
relationships
public Relationships relationships()
ReturnsRelationships
representing the Cognite relationships api endpoint.- Returns:
- The relationships api object.
-
sequences
public Sequences sequences()
ReturnsSequences
representing the Cognite sequences api endpoint.- Returns:
- The sequences api object.
-
labels
public Labels labels()
ReturnsLabels
representing the Cognite labels api endpoints.- Returns:
- The labels api endpoint.
-
datasets
public Datasets datasets()
ReturnsDatasets
representing the Cognite dats sets api endpoint.- Returns:
- The data sets api object.
-
securityCategories
public SecurityCategories securityCategories()
ReturnsSecurityCategories
representing the Cognite labels api endpoints.- Returns:
- The security categories api endpoint.
-
contextualization
public Contextualization contextualization()
ReturnsContextualization
representing the Cognite contextualization api endpoints.- Returns:
- The contextualization api endpoint.
-
experimental
public Experimental experimental()
ReturnsExperimental
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
-
-