Show / Hide Table of Contents

Class CogniteDestination

Class with utility methods supporting extraction of data into CDF. These methods complement the ones offered by the CogniteSdk.Client and use a CogniteConfig object to determine chunking of data and throttling of requests against the client

Inheritance
object
CogniteDestination
CogniteDestinationWithIDM
Implements
IRawDestination
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Cognite.Extractor.Utils
Assembly: ExtractorUtils.dll
Syntax
public class CogniteDestination : IRawDestination

Constructors

| Edit this page View Source

CogniteDestination(Client, ILogger<CogniteDestination>, CogniteConfig)

Initializes the Cognite destination with the provided parameters

Declaration
public CogniteDestination(Client client, ILogger<CogniteDestination> logger, CogniteConfig config)
Parameters
Type Name Description
Client client

CogniteSdk.Client object

ILogger<CogniteDestination> logger

Logger

CogniteConfig config

Configuration object

| Edit this page View Source

CogniteDestination(Client, ILogger<CogniteDestination>, BaseCogniteConfig, string)

Initializes the Cognite destination with the provided parameters

Declaration
public CogniteDestination(Client client, ILogger<CogniteDestination> logger, BaseCogniteConfig config, string project)
Parameters
Type Name Description
Client client

CogniteSdk.Client object

ILogger<CogniteDestination> logger

Logger

BaseCogniteConfig config

Configuration object

string project

Configured project

Properties

| Edit this page View Source

Chunking

Configuration for chunking.

Declaration
protected ChunkingConfig Chunking { get; }
Property Value
Type Description
ChunkingConfig
| Edit this page View Source

CogniteClient

The configured Cognite client used by this destination. Can be used to access the full Cognite API

Declaration
public Client CogniteClient { get; }
Property Value
Type Description
Client
| Edit this page View Source

NanReplacement

Configuration for replacing NaN with a number.

Declaration
protected double? NanReplacement { get; }
Property Value
Type Description
double?
| Edit this page View Source

Throttling

Configuration for throttling.

Declaration
protected ThrottlingConfig Throttling { get; }
Property Value
Type Description
ThrottlingConfig

Methods

| Edit this page View Source

CreateEventUploadQueue(TimeSpan, int, Func<QueueUploadResult<EventCreate>, Task>?, string?)

Creates an event upload queue. It is used to queue events before uploading them to CDF. The items are dequeued and uploaded every interval. If maxQueueSize is greater than zero, the queue will have a maximum size, and items are also uploaded as soon as the maximum size is reached. If interval is zero or infinite, the queue will never upload unless prompted or maxQueueSize is reached. To start the upload loop, use the Start(CancellationToken) method. To stop it, dispose of the queue or cancel the token

Declaration
public EventUploadQueue CreateEventUploadQueue(TimeSpan interval, int maxQueueSize = 0, Func<QueueUploadResult<EventCreate>, Task>? callback = null, string? bufferPath = null)
Parameters
Type Name Description
TimeSpan interval

Upload interval

int maxQueueSize

Maximum queue size

Func<QueueUploadResult<EventCreate>, Task> callback

Callback on upload

string bufferPath

Path to local binary buffer file. If this is non-null, points are automatically buffered to a local file if inserting times out or fails with status >= 500

Returns
Type Description
EventUploadQueue

An upload queue object

| Edit this page View Source

CreateRawUploadQueue<T>(string, string, TimeSpan, int, Func<QueueUploadResult<(string key, T columns)>, Task>?)

Creates a Raw upload queue. It can be used to queue DTOs (data type objects) of type T before sending them to CDF Raw. The items are dequeued and uploaded every interval. If maxQueueSize is greater than zero, the queue will have a maximum size, and items are also uploaded as soon as the maximum size is reached. To start the upload loop, use the Start(CancellationToken) method. To stop it, dispose of the queue or cancel the token

Declaration
public IRawUploadQueue<T> CreateRawUploadQueue<T>(string database, string table, TimeSpan interval, int maxQueueSize = 0, Func<QueueUploadResult<(string key, T columns)>, Task>? callback = null)
Parameters
Type Name Description
string database

Raw database name

string table

Raw table name

TimeSpan interval

Upload interval

int maxQueueSize

Maximum queue size

Func<QueueUploadResult<(string key, T columns)>, Task> callback

Callback on upload

Returns
Type Description
IRawUploadQueue<T>

An upload queue object

Type Parameters
Name Description
T

Type of the DTO

| Edit this page View Source

CreateTimeSeriesUploadQueue(TimeSpan, int, Func<QueueUploadResult<(Identity id, Datapoint dp)>, Task>?, string?)

Creates a datapoint upload queue. It is used to queue datapoints before uploading them to timeseries in CDF. The items are dequeued and uploaded every interval. If maxQueueSize is greater than zero, the queue will have a maximum size, and items are also uploaded as soon as the maximum size is reached. If interval is zero or infinite, the queue will never upload unless prompted or maxQueueSize is reached. To start the upload loop, use the Start(CancellationToken) method. To stop it, dispose of the queue or cancel the token

Declaration
public TimeSeriesUploadQueue CreateTimeSeriesUploadQueue(TimeSpan interval, int maxQueueSize = 0, Func<QueueUploadResult<(Identity id, Datapoint dp)>, Task>? callback = null, string? bufferPath = null)
Parameters
Type Name Description
TimeSpan interval

Upload interval

int maxQueueSize

Maximum queue size

Func<QueueUploadResult<(Identity id, Datapoint dp)>, Task> callback

Callback on upload

string bufferPath

Path to local binary buffer file. If this is non-null, points are automatically buffered to a local file if inserting times out or fails with status >= 500

Returns
Type Description
TimeSeriesUploadQueue

An upload queue object

| Edit this page View Source

DeleteDataPointsIgnoreErrorsAsync(IDictionary<Identity, IEnumerable<TimeRange>>?, CancellationToken)

Deletes ranges of data points in CDF. The ranges parameter contains the first (inclusive) and last (inclusive) timestamps for the range. After the delete request is sent to CDF, attempt to confirm that the data points were deleted by querying the time range. Deletes in CDF are eventually consistent, failing to confirm the deletion does not mean that the operation failed in CDF

Declaration
public Task<DeleteError> DeleteDataPointsIgnoreErrorsAsync(IDictionary<Identity, IEnumerable<TimeRange>>? ranges, CancellationToken token)
Parameters
Type Name Description
IDictionary<Identity, IEnumerable<TimeRange>> ranges

Ranges to delete

CancellationToken token

Cancelation token

Returns
Type Description
Task<DeleteError>

A DeleteError object with any missing ids or ids with unconfirmed deletes

| Edit this page View Source

DeleteRowsAsync(string, string, IEnumerable<string>, CancellationToken)

Delete the given rows from raw database

Declaration
public Task DeleteRowsAsync(string dbName, string tableName, IEnumerable<string> rowKeys, CancellationToken token)
Parameters
Type Name Description
string dbName

Database to delete from

string tableName

Table to delete from

IEnumerable<string> rowKeys

Keys for rows to delete

CancellationToken token

Cancellation token

Returns
Type Description
Task
| Edit this page View Source

EnsureAssetsExistsAsync(IEnumerable<AssetCreate>, RetryMode, SanitationMode, CancellationToken)

Ensures that all assets in assets exist in CDF. Tries to create the assets and returns when all are created or have been removed due to issues with the request. By default, if any items fail to be created due to missing parent, duplicated externalId or missing dataset they can be removed before retrying by setting retryMode. Assets will be returned in the same order as given in assets.

Declaration
public Task<CogniteResult<Asset, AssetCreate>> EnsureAssetsExistsAsync(IEnumerable<AssetCreate> assets, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<AssetCreate> assets

List of CogniteSdk AssetCreate objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to assets before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Asset, AssetCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created assets

| Edit this page View Source

EnsureEventsExistsAsync(IEnumerable<EventCreate>, RetryMode, SanitationMode, CancellationToken)

Ensures that all events in events exist in CDF. Tries to create the events and returns when all are created or removed due to issues with the request. If any items fail to be pushed due to missing assetIds, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode Events will be returned in the same order as given in events.

Declaration
public Task<CogniteResult<Event, EventCreate>> EnsureEventsExistsAsync(IEnumerable<EventCreate> events, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<EventCreate> events

List of CogniteSdk EventCreate objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to events before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Event, EventCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created events

| Edit this page View Source

EnsureSequencesExistsAsync(IEnumerable<SequenceCreate>, RetryMode, SanitationMode, CancellationToken)

Ensures that all sequences in sequences exist in CDF. Tries to create the sequences and returns when all are created or removed due to issues with the request. If any items fail to be pushed due to missing assetId, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode Sequences will be returned in the same order as given in sequences.

Declaration
public Task<CogniteResult<Sequence, SequenceCreate>> EnsureSequencesExistsAsync(IEnumerable<SequenceCreate> sequences, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<SequenceCreate> sequences

List of CogniteSdk SequenceCreate objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to sequences before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Sequence, SequenceCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created sequences

| Edit this page View Source

EnsureTimeSeriesExistsAsync(IEnumerable<TimeSeriesCreate>, RetryMode, SanitationMode, CancellationToken)

Ensures that all time series in timeSeries exist in CDF. Tries to create the time series and returns when all are created or have been removed due to issues with the request. By default, if any items fail to be created due to missing asset, duplicated externalId, duplicated legacy name, or missing dataSetId, they can be removed before retrying by setting retryMode Timeseries will be returned in the same order as given in timeSeries

Declaration
public Task<CogniteResult<TimeSeries, TimeSeriesCreate>> EnsureTimeSeriesExistsAsync(IEnumerable<TimeSeriesCreate> timeSeries, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<TimeSeriesCreate> timeSeries

List of CogniteSdk TimeSeriesCreate objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to timeseries before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<TimeSeries, TimeSeriesCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created timeseries

| Edit this page View Source

GetExtractedRanges(IEnumerable<Identity>, CancellationToken, bool, bool)

Fetches the range of datapoints present in CDF. Limited by given ranges for each id. Note that end limits closer to actual endpoints in CDF is considerably faster.

Declaration
public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(IEnumerable<Identity> ids, CancellationToken token, bool earliest = true, bool latest = true)
Parameters
Type Name Description
IEnumerable<Identity> ids

ExternalIds and start/end of region to look for datapoints. Use TimeRange.Complete for first after epoch, and last before now.

CancellationToken token

Cancellation token

bool earliest

If true, fetch earliest timestamps, default true

bool latest

If true, fetch latest timestamps, default true

Returns
Type Description
Task<IDictionary<Identity, TimeRange>>
| Edit this page View Source

GetExtractedRanges(IEnumerable<(Identity id, TimeRange limit)>, CancellationToken, bool, bool)

Fetches the range of datapoints present in CDF. Limited by given ranges for each id. Note that end limits closer to actual endpoints in CDF is considerably faster.

Declaration
public Task<IDictionary<Identity, TimeRange>> GetExtractedRanges(IEnumerable<(Identity id, TimeRange limit)> ids, CancellationToken token, bool earliest = true, bool latest = true)
Parameters
Type Name Description
IEnumerable<(Identity id, TimeRange limit)> ids

ExternalIds and start/end of region to look for datapoints. Use TimeRange.Complete for first after epoch, and last before now.

CancellationToken token

Cancellation token

bool earliest

If true, fetch earliest timestamps, default true

bool latest

If true, fetch latest timestamps, default true

Returns
Type Description
Task<IDictionary<Identity, TimeRange>>
| Edit this page View Source

GetOrCreateAssetsAsync(IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<AssetCreate>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the assets with the provided externalIds exist in CDF. If one or more do not exist, use the buildAssets function to construct the missing asset objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be created due to missing parent, duplicated externalId or missing dataset they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Asset, AssetCreate>> GetOrCreateAssetsAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<AssetCreate>> buildAssets, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, IEnumerable<AssetCreate>> buildAssets

Function that builds CogniteSdk AssetCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to assets before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Asset, AssetCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found assets

| Edit this page View Source

GetOrCreateAssetsAsync(IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<AssetCreate>>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the assets with the provided externalIds exist in CDF. If one or more do not exist, use the buildAssets function to construct the missing asset objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be created due to missing parent, duplicated externalId or missing dataset they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Asset, AssetCreate>> GetOrCreateAssetsAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<AssetCreate>>> buildAssets, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, Task<IEnumerable<AssetCreate>>> buildAssets

Async function that builds CogniteSdk AssetCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to assets before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Asset, AssetCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found assets

| Edit this page View Source

GetOrCreateEventsAsync(IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<EventCreate>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the events with the provided externalIds exist in CDF. If one or more do not exist, use the buildEvents function to construct the missing event objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be pushed due to missing assetIds, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Event, EventCreate>> GetOrCreateEventsAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<EventCreate>> buildEvents, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, IEnumerable<EventCreate>> buildEvents

Function that builds CogniteSdk EventCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to events before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Event, EventCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found events

| Edit this page View Source

GetOrCreateEventsAsync(IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<EventCreate>>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the events with the provided externalIds exist in CDF. If one or more do not exist, use the buildEvents function to construct the missing event objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be pushed due to missing assetIds, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Event, EventCreate>> GetOrCreateEventsAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<EventCreate>>> buildEvents, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, Task<IEnumerable<EventCreate>>> buildEvents

Async function that builds CogniteSdk EventCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to events before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Event, EventCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found events

| Edit this page View Source

GetOrCreateSequencesAsync(IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<SequenceCreate>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the sequences with the provided externalIds exist in CDF. If one or more do not exist, use the buildSequences function to construct the missing sequence objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be pushed due to missing assetId, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Sequence, SequenceCreate>> GetOrCreateSequencesAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<SequenceCreate>> buildSequences, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, IEnumerable<SequenceCreate>> buildSequences

Function that builds CogniteSdk SequenceCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to sequences before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Sequence, SequenceCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found sequences

| Edit this page View Source

GetOrCreateSequencesAsync(IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<SequenceCreate>>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the sequences with the provided externalIds exist in CDF. If one or more do not exist, use the buildSequences function to construct the missing sequence objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be pushed due to missing assetId, missing dataset, or duplicated externalId they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<Sequence, SequenceCreate>> GetOrCreateSequencesAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<SequenceCreate>>> buildSequences, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, Task<IEnumerable<SequenceCreate>>> buildSequences

Async function that builds CogniteSdk SequenceCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to sequences before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Sequence, SequenceCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found sequences

| Edit this page View Source

GetOrCreateStreamAsync(StreamWrite, CancellationToken)

Retrieve a stream, or create it if it does not exist.

Declaration
public Task<Stream> GetOrCreateStreamAsync(StreamWrite stream, CancellationToken token)
Parameters
Type Name Description
StreamWrite stream

Stream to create or retrieve

CancellationToken token

Cancellation token

Returns
Type Description
Task<Stream>

Created or retrieved stream

Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

GetOrCreateTimeSeriesAsync(IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<TimeSeriesCreate>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the time series with the provided externalIds exist in CDF. If one or more do not exist, use the buildTimeSeries function to construct the missing time series objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF If any items fail to be created due to missing asset, duplicated externalId, duplicated legacy name, or missing dataSetId, they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<TimeSeries, TimeSeriesCreate>> GetOrCreateTimeSeriesAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<TimeSeriesCreate>> buildTimeSeries, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, IEnumerable<TimeSeriesCreate>> buildTimeSeries

Function that builds CogniteSdk TimeSeriesCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to timeseries before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<TimeSeries, TimeSeriesCreate>>

A CogniteResult<TResult, TError> containing errors that occurred and a list of the created and found timeseries

| Edit this page View Source

GetOrCreateTimeSeriesAsync(IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<TimeSeriesCreate>>>, RetryMode, SanitationMode, CancellationToken)

Ensures the the time series with the provided externalIds exist in CDF. If one or more do not exist, use the buildTimeSeries function to construct the missing time series objects and upload them to CDF. This method uses the CogniteConfig object to determine chunking of items and throttling against CDF By default, if any items fail to be created due to missing asset, duplicated externalId, duplicated legacy name, or missing dataSetId, they can be removed before retrying by setting retryMode

Declaration
public Task<CogniteResult<TimeSeries, TimeSeriesCreate>> GetOrCreateTimeSeriesAsync(IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<TimeSeriesCreate>>> buildTimeSeries, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<string> externalIds

External Ids

Func<IEnumerable<string>, Task<IEnumerable<TimeSeriesCreate>>> buildTimeSeries

Async function that builds CogniteSdk TimeSeriesCreate objects

RetryMode retryMode

How to handle failed requests

SanitationMode sanitationMode

The type of sanitation to apply to timeseries before creating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<TimeSeries, TimeSeriesCreate>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the created and found timeseries

| Edit this page View Source

GetRowsAsync(string, string, JsonSerializerOptions?, CancellationToken)

Returns all rows from the given database and table

Declaration
public Task<IDictionary<string, IDictionary<string, JsonElement>>> GetRowsAsync(string dbName, string tableName, JsonSerializerOptions? options, CancellationToken token)
Parameters
Type Name Description
string dbName

Database to read from

string tableName

Table to read from

JsonSerializerOptions options

Optional json serializer options

CancellationToken token

Cancellation token

Returns
Type Description
Task<IDictionary<string, IDictionary<string, JsonElement>>>

All rows

| Edit this page View Source

GetRowsAsync<T>(string, string, JsonSerializerOptions?, CancellationToken)

Returns all rows from the given database and table

Declaration
public Task<IDictionary<string, T>> GetRowsAsync<T>(string dbName, string tableName, JsonSerializerOptions? options, CancellationToken token)
Parameters
Type Name Description
string dbName

Database to read from

string tableName

Table to read from

JsonSerializerOptions options

Optional json serializer options

CancellationToken token

Cancellation token

Returns
Type Description
Task<IDictionary<string, T>>

All rows

Type Parameters
Name Description
T
| Edit this page View Source

InsertDataPointsAsync(IDictionary<Identity, IEnumerable<Datapoint>>?, SanitationMode, RetryMode, CancellationToken)

Insert the provided data points into CDF. The data points are chunked according to CdfChunking and trimmed according to the CDF limits. The points dictionary keys are time series identities (Id or ExternalId) and the values are numeric or string data points

On error, the offending timeseries/datapoints can optionally be removed.

Declaration
public Task<CogniteResult<DataPointInsertError>> InsertDataPointsAsync(IDictionary<Identity, IEnumerable<Datapoint>>? points, SanitationMode sanitationMode, RetryMode retryMode, CancellationToken token)
Parameters
Type Name Description
IDictionary<Identity, IEnumerable<Datapoint>> points

Data points

SanitationMode sanitationMode
RetryMode retryMode
CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<DataPointInsertError>>
| Edit this page View Source

InsertDataPointsCreateMissingAsync(IDictionary<Identity, IEnumerable<Datapoint>>?, SanitationMode, RetryMode, long?, CancellationToken)

Insert datapoints to timeseries. Insertions are chunked and cleaned according to configuration, and can optionally handle errors. If any timeseries missing from the result and inserted by externalId, they are created before the points are inserted again.

Declaration
public Task<(CogniteResult<DataPointInsertError> DataPointResult, CogniteResult<TimeSeries, TimeSeriesCreate>? TimeSeriesResult)> InsertDataPointsCreateMissingAsync(IDictionary<Identity, IEnumerable<Datapoint>>? points, SanitationMode sanitationMode, RetryMode retryMode, long? dataSetId, CancellationToken token)
Parameters
Type Name Description
IDictionary<Identity, IEnumerable<Datapoint>> points

Datapoints to insert

SanitationMode sanitationMode

How to sanitize datapoints

RetryMode retryMode

How to handle retries

long? dataSetId

Optional data set id

CancellationToken token

Cancellation token

Returns
Type Description
Task<(CogniteResult<DataPointInsertError> DataPointResult, CogniteResult<TimeSeries, TimeSeriesCreate> TimeSeriesResult)>

Results with a list of errors. If TimeSeriesResult is null, no timeseries were attempted created.

| Edit this page View Source

InsertRawRowsAsync<T>(string, string, IDictionary<string, T>, JsonSerializerOptions?, CancellationToken)

Insert the provided rows into CDF Raw. The rows are a dictionary of keys and DTOs (data type objects). The DTOs of type T are serialized to JSON before they are sent to Raw. If the database or table do not exist, they are created

Declaration
public Task InsertRawRowsAsync<T>(string database, string table, IDictionary<string, T> rows, JsonSerializerOptions? options, CancellationToken token)
Parameters
Type Name Description
string database

Raw database name

string table

Raw table name

IDictionary<string, T> rows

Rows of keys and columns

JsonSerializerOptions options

Optional JSON options parameter, to be used when converting dto to JsonElement

CancellationToken token

Cancellation token

Returns
Type Description
Task

Task

Type Parameters
Name Description
T

DTO type

| Edit this page View Source

InsertRawRowsAsync<T>(string, string, IDictionary<string, T>?, CancellationToken)

Insert the provided rows into CDF Raw. The rows are a dictionary of keys and DTOs (data type objects). The DTOs of type T are serialized to JSON before they are sent to Raw. If the database or table do not exist, they are created

Declaration
public Task InsertRawRowsAsync<T>(string database, string table, IDictionary<string, T>? rows, CancellationToken token)
Parameters
Type Name Description
string database

Raw database name

string table

Raw table name

IDictionary<string, T> rows

Rows of keys and columns

CancellationToken token

Cancellation token

Returns
Type Description
Task

Task

Type Parameters
Name Description
T

DTO type

| Edit this page View Source

InsertRecordsAsync(string, ICollection<StreamRecordWrite>, CancellationToken)

Insert the given stream records into stream. The stream must exist.

Declaration
public Task InsertRecordsAsync(string stream, ICollection<StreamRecordWrite> records, CancellationToken token)
Parameters
Type Name Description
string stream

Stream to ingest into

ICollection<StreamRecordWrite> records

Stream records to insert

CancellationToken token

Cancellation token

Returns
Type Description
Task
Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

InsertSequenceRowsAsync(IEnumerable<SequenceDataCreate>, RetryMode, SanitationMode, CancellationToken)

Insert the given list of rows into CDF. Both individual rows and full sequences can be removed due to mismatched datatypes, duplicated externalIds, or similar, by setting retryMode and sanitationMode.

Declaration
public Task<CogniteResult<SequenceRowError>> InsertSequenceRowsAsync(IEnumerable<SequenceDataCreate> sequences, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<SequenceDataCreate> sequences

Sequences with rows to insert

RetryMode retryMode

How to handle retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to sequences before creating. Errors that are normally handled by sanitation will not be handled if received from CDF.

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<SequenceRowError>>

A CogniteResult<TError> containing errors that occured during insertion

| Edit this page View Source

TestCogniteConfig(CancellationToken)

Verifies that the currently configured Cognite client can access Cognite Data Fusion

Declaration
public Task TestCogniteConfig(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

Cancellation token

Returns
Type Description
Task
Exceptions
Type Condition
CogniteUtilsException

Thrown when credentials are invalid

| Edit this page View Source

UpdateAssetsAsync(IEnumerable<AssetUpdateItem>, RetryMode, SanitationMode, CancellationToken)

Update assets in updates. If items fail due to bad parent ids, id, labels or dataset they can be removed before retrying by setting retryMode. Assets will be returned in the same order as given.

Declaration
public Task<CogniteResult<Asset, AssetUpdateItem>> UpdateAssetsAsync(IEnumerable<AssetUpdateItem> updates, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<AssetUpdateItem> updates

List of CogniteSdk AssetUpdateItem objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to assets before updating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Asset, AssetUpdateItem>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the updated assets

| Edit this page View Source

UpdateTimeSeriesAsync(IEnumerable<TimeSeriesUpdateItem>, RetryMode, SanitationMode, CancellationToken)

Update timeseries in updates. If items fail due to bad asset ids, id, or dataset they can be removed before retrying by setting retryMode. TimeSeries will be returned in the same order as given.

Declaration
public Task<CogniteResult<TimeSeries, TimeSeriesUpdateItem>> UpdateTimeSeriesAsync(IEnumerable<TimeSeriesUpdateItem> updates, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
IEnumerable<TimeSeriesUpdateItem> updates

List of CogniteSdk TimeSeriesUpdateItem objects

RetryMode retryMode

How to do retries. Keeping duplicates is not valid for this method.

SanitationMode sanitationMode

The type of sanitation to apply to assets before updating

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<TimeSeries, TimeSeriesUpdateItem>>

A CogniteResult<TResult, TError> containing errors that occured and a list of the updated timeseries

| Edit this page View Source

UpsertAssetsAsync(IEnumerable<AssetCreate>, RetryMode, SanitationMode, UpsertParams?, CancellationToken)

Insert or update a list of assets, handling errors that come up during both insert and update. Only assets that differ from assets in CDF are updated.

All given assets must have an external id, so it is not in practice possible to use this to change the externalId of assets.

Assets are returned in the same order as given.

Declaration
public Task<CogniteResult<Asset, AssetCreate>> UpsertAssetsAsync(IEnumerable<AssetCreate> upserts, RetryMode retryMode, SanitationMode sanitationMode, UpsertParams? options, CancellationToken token)
Parameters
Type Name Description
IEnumerable<AssetCreate> upserts

Assets to upsert

RetryMode retryMode

How to handle retries on errors

SanitationMode sanitationMode

How to sanitize creates and updates

UpsertParams options

How to update existing assets

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<Asset, AssetCreate>>

Result with failed creates/updates and list of assets

Exceptions
Type Condition
ArgumentException

All upserted assets must have external id

| Edit this page View Source

UpsertTimeSeriesAsync(IEnumerable<TimeSeriesCreate>, RetryMode, SanitationMode, UpsertParams?, CancellationToken)

Insert or update a list of timeseries, handling errors that come up during both insert and update. Only timeseries that differ from timeseries in CDF are updated.

All given timeseries must have an external id, so it is not in practice possible to use this to change the externalId of timeseries.

Timeseries are returned in the same order as given.

Declaration
public Task<CogniteResult<TimeSeries, TimeSeriesCreate>> UpsertTimeSeriesAsync(IEnumerable<TimeSeriesCreate> upserts, RetryMode retryMode, SanitationMode sanitationMode, UpsertParams? options, CancellationToken token)
Parameters
Type Name Description
IEnumerable<TimeSeriesCreate> upserts

Assets to upsert

RetryMode retryMode

How to handle retries on errors

SanitationMode sanitationMode

How to sanitize creates and updates

UpsertParams options

How to update existing assets

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<TimeSeries, TimeSeriesCreate>>

Result with failed creates/updates and list of assets

Exceptions
Type Condition
ArgumentException

All upserted assets must have external id

Implements

IRawDestination

Extension Methods

DataModelUtils.GetOrCreateResourcesAsync<T, T2>(T2, IEnumerable<InstanceIdentifier>, Func<IEnumerable<InstanceIdentifier>, IEnumerable<SourcedNodeWrite<T>>>, Func<IEnumerable<SourcedNodeWrite<T>>, SanitationMode, (IEnumerable<SourcedNodeWrite<T>>, IEnumerable<CogniteError<SourcedNodeWrite<T>>>)>, int, int, RetryMode, SanitationMode, CancellationToken)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX