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 classCogniteClient.AuthType
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerLOG
-
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 Assetsassets()ReturnsAssetsrepresenting the Cognite assets api endpoint.protected AuthConfigbuildAuthConfig()Returns a auth info for api requestsContextualizationcontextualization()ReturnsContextualizationrepresenting the Cognite contextualization api endpoints.static CogniteClientcreate()Deprecated.Datasetsdatasets()ReturnsDatasetsrepresenting the Cognite dats sets api endpoint.CogniteClientenableHttp(boolean enable)Enable (or disable) support for http.Eventsevents()ReturnsEventsrepresenting the Cognite events api endpoint.Experimentalexperimental()ReturnsExperimentalrepresenting experimental (non-released) api endpoints.ExtractionPipelinesextractionPipelines()ReturnsExtractionPipelinesrepresenting the Cognite extraction pipelines api endpoint.Filesfiles()ReturnsFilesrepresenting the Cognite files api endpoints.protected abstract StringgetApiKey()protected abstract Collection<String>getAuthScopes()protected abstract CogniteClient.AuthTypegetAuthType()protected abstract StringgetBaseUrl()abstract ClientConfiggetClientConfig()protected abstract StringgetClientId()protected abstract StringgetClientSecret()protected ConnectorServiceV1getConnectorService()Returns the services layer mirroring the Cognite Data Fusion API.ExecutorServicegetExecutorService()abstract okhttp3.OkHttpClientgetHttpClient()protected abstract StringgetProject()protected abstract Supplier<String>getTokenSupplier()protected abstract URLgetTokenUrl()ExecutorServicegetTsExecutorService()Labelslabels()ReturnsLabelsrepresenting the Cognite labels api endpoints.Loginlogin()ReturnsLoginrepresenting login status api endpoints.static CogniteClientofClientCredentials(String cdfProject, String clientId, String clientSecret, URL tokenUrl)Returns aCogniteClientusing client credentials for authentication.static CogniteClientofClientCredentials(String cdfProject, String clientId, String clientSecret, URL tokenUrl, Collection<String> scopes)Returns aCogniteClientusing client credentials for authentication.static CogniteClientofClientCredentials(String clientId, String clientSecret, URL tokenUrl)Deprecated.static CogniteClientofClientCredentials(String clientId, String clientSecret, URL tokenUrl, Collection<String> scopes)Deprecated.static CogniteClientofKey(String apiKey)Deprecated.static CogniteClientofToken(String cdfProject, Supplier<String> tokenSupplier)Deprecated.static CogniteClientofToken(Supplier<String> tokenSupplier)Deprecated.Rawraw()ReturnsRawrepresenting the Cognite Raw service.Relationshipsrelationships()ReturnsRelationshipsrepresenting the Cognite relationships api endpoint.SecurityCategoriessecurityCategories()ReturnsSecurityCategoriesrepresenting the Cognite labels api endpoints.Sequencessequences()ReturnsSequencesrepresenting the Cognite sequences api endpoint.ThreeDthreeD()ReturnsThreeDrepresenting 3D api endpoints.Timeseriestimeseries()ReturnsTimeseriesrepresenting the Cognite timeseries api endpoint.protected abstract com.cognite.client.CogniteClient.BuildertoBuilder()Transformationstransformations()ReturnsTransformationsrepresenting Transformation api endpoints.CogniteClientwithBaseUrl(String baseUrl)Returns aCogniteClientusing the specified base URL for issuing API requests.CogniteClientwithClientConfig(ClientConfig config)Returns aCogniteClientusing the specified configuration settings.CogniteClientwithProject(String project)Returns aCogniteClientusing the specified Cognite Data Fusion project / tenant.CogniteClientwithScopes(Collection<String> scopes)Returns aCogniteClientusing the specified list of scopes for issuing API requests.
-
-
-
Method Detail
-
create
@Deprecated public static CogniteClient create() throws Exception
Deprecated.Returns aCogniteClientusing 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
@Deprecated public static CogniteClient ofKey(String apiKey)
Deprecated.Returns aCogniteClientusing 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
@Deprecated public static CogniteClient ofToken(Supplier<String> tokenSupplier)
Deprecated.Returns aCogniteClientusing the provided supplier (function) to provide a bearer token for authorization. If your application handles the authentication flow itself, you can pass aSupplierto 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.
-
ofToken
@Deprecated public static CogniteClient ofToken(String cdfProject, Supplier<String> tokenSupplier)
Deprecated.Returns aCogniteClientusing the provided supplier (function) to provide a bearer token for authorization. If your application handles the authentication flow itself, you can pass aSupplierto 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:
cdfProject- The CDF project to connect to.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 cdfProject, String clientId, String clientSecret, URL tokenUrl, Collection<String> scopes)
Returns aCogniteClientusing 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:
cdfProject- The CDF project to connect to.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.scopes- The list of scopes to be used for authentication- Returns:
- the client object with default configuration.
-
ofClientCredentials
@Deprecated public static CogniteClient ofClientCredentials(String clientId, String clientSecret, URL tokenUrl, Collection<String> scopes)
Deprecated.Returns aCogniteClientusing 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.scopes- The list of scopes to be used for authentication- Returns:
- the client object with default configuration.
-
ofClientCredentials
public static CogniteClient ofClientCredentials(String cdfProject, String clientId, String clientSecret, URL tokenUrl)
Returns aCogniteClientusing 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:
cdfProject- The CDF project to connect to.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.
-
ofClientCredentials
@Deprecated public static CogniteClient ofClientCredentials(String clientId, String clientSecret, URL tokenUrl)
Deprecated.Returns aCogniteClientusing 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()
-
getAuthScopes
@Nullable protected abstract Collection<String> getAuthScopes()
-
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()
-
getTsExecutorService
public ExecutorService getTsExecutorService()
-
withProject
public CogniteClient withProject(String project)
Returns aCogniteClientusing 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 aCogniteClientusing 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.
-
withScopes
public CogniteClient withScopes(Collection<String> scopes)
Returns aCogniteClientusing the specified list of scopes for issuing API requests.- Parameters:
scopes- The collection of scopes to be used for OAuth2.0 authentication- Returns:
- the client object with the authentication handler configured
-
withClientConfig
public CogniteClient withClientConfig(ClientConfig config)
Returns aCogniteClientusing the specified configuration settings.- Parameters:
config- TheClientConfighosting 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 totrueto enable support for http calls. Set tofalseto disable support for http (then only https will be possible). The default setting isdisabled. I.e. only https calls are allowed.- Parameters:
enable- Set totrueto enable support for http calls. Set tofalseto disable support for http.- Returns:
- the client object with the config applied.
-
assets
public Assets assets()
ReturnsAssetsrepresenting the Cognite assets api endpoint.- Returns:
- The assets api object.
-
timeseries
public Timeseries timeseries()
ReturnsTimeseriesrepresenting the Cognite timeseries api endpoint.- Returns:
- The timeseries api object.
-
events
public Events events()
ReturnsEventsrepresenting the Cognite events api endpoint.- Returns:
- The events api object.
-
files
public Files files()
ReturnsFilesrepresenting the Cognite files api endpoints.- Returns:
- The labels api endpoint.
-
relationships
public Relationships relationships()
ReturnsRelationshipsrepresenting the Cognite relationships api endpoint.- Returns:
- The relationships api object.
-
sequences
public Sequences sequences()
ReturnsSequencesrepresenting the Cognite sequences api endpoint.- Returns:
- The sequences api object.
-
labels
public Labels labels()
ReturnsLabelsrepresenting the Cognite labels api endpoints.- Returns:
- The labels api endpoint.
-
datasets
public Datasets datasets()
ReturnsDatasetsrepresenting the Cognite dats sets api endpoint.- Returns:
- The data sets api object.
-
extractionPipelines
public ExtractionPipelines extractionPipelines()
ReturnsExtractionPipelinesrepresenting the Cognite extraction pipelines api endpoint.- Returns:
- The extraction pipelines api object.
-
securityCategories
public SecurityCategories securityCategories()
ReturnsSecurityCategoriesrepresenting the Cognite labels api endpoints.- Returns:
- The security categories api endpoint.
-
contextualization
public Contextualization contextualization()
ReturnsContextualizationrepresenting the Cognite contextualization api endpoints.- Returns:
- The contextualization api endpoint.
-
experimental
public Experimental experimental()
ReturnsExperimentalrepresenting experimental (non-released) api endpoints.- Returns:
- The Experimental api endpoints.
-
login
public Login login() throws Exception
ReturnsLoginrepresenting login status api endpoints.- Returns:
- The LoginStatus api endpoints.
- Throws:
Exception
-
threeD
public ThreeD threeD()
ReturnsThreeDrepresenting 3D api endpoints.- Returns:
- The ThreeD api endpoints.
-
transformations
public Transformations transformations()
ReturnsTransformationsrepresenting Transformation api endpoints.- Returns:
- The Transformation 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
-
-