cognitedata / cdf-sdk-java

Java SDK for Cognite Data Fusion
Apache License 2.0
4 stars 8 forks source link

java-main Actions Status

Cognite logo

Java sdk for CDF

The Java SDK provides convenient access to Cognite Data Fusion's capabilities. It covers a large part of CDF's capability surface, including experimental features. In addition, it is designed to handle a lot of the client "chores" for you so you can spend more time on your core client logic.

Some of the SDK's capabilities:

Requirements SDK v2:

Requirements SDK v1:

Please refer to the documentation for more information: ./docs/index.md.

Upcoming SDK v2

We have a new major version of the Java SDK in the pipeline. It is based on the v1 code line, but with a few breaking changes, so we bump it to a new major version. The main breaking changes include:

It should not be too hard to move from v1 to v2 and we'll provide a migration guide for you.

Installing the sdk

SDK v2

<dependency>    
    <groupId>com.cognite</groupId>
    <artifactId>cdf-sdk-java</artifactId>
    <version>2.3.0</version>
</dependency>

SDK v1

<dependency>    
    <groupId>com.cognite</groupId>
    <artifactId>cdf-sdk-java</artifactId>
    <version>1.19.1</version>
</dependency>

Features

Core resource types

Data organization

Contextualization

3D

TRANSFORMATIONS

Quickstart

// Create the Cognite client with client credentials (OpenID Connect)
CogniteClient client = CogniteClient.ofClientCredentials(
        <cdfProject>,
        <clientId>,
        <clientSecret>,
        TokenUrl.generateAzureAdURL(<azureAdTenantId>))
        .withBaseUrl("https://yourBaseURL.cognitedata.com"); //optional parameter     

// List all assets
List<Asset> listAssetsResults = new ArrayList<>();
client.assets()
        .list(Request.create()
                .withFilterParameter("key", "value"))       //optionally add filter parameters
        .forEachRemaining(assetBatch -> listAssetsResults.addAll(assetBatch));        //results are read in batches

// List all events
List<Event> listEventsResults = new ArrayList<>();
client.events()
        .list(Request.create()
                .withFilterParameter("key", "value"))       //optionally add filter parameters
        .forEachRemaining(eventBatch -> listEventsResults.addAll(eventBatch));        //results are read in batches

Open in Cloud Shell