Show / Hide Table of Contents

Class TimeSeriesExtensions

Extension utility methods for CogniteSdk.Client

Inheritance
object
TimeSeriesExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public static class TimeSeriesExtensions

Methods

| Edit this page View Source

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

Ensures that all time series in timeSeriesToEnsure 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. 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 timeSeriesToEnsure

Declaration
public static Task<CogniteResult<TimeSeries, TimeSeriesCreate>> EnsureTimeSeriesExistsAsync(this TimeSeriesResource timeseries, IEnumerable<TimeSeriesCreate> timeSeriesToEnsure, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource timeseries

Cognite client

IEnumerable<TimeSeriesCreate> timeSeriesToEnsure

List of CogniteSdk TimeSeriesCreate objects

int chunkSize

Chunk size

int throttleSize

Throttle size

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

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

Get or create 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 using the chunking of items and throttling passed as parameters 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 static Task<CogniteResult<TimeSeries, TimeSeriesCreate>> GetOrCreateTimeSeriesAsync(this TimeSeriesResource timeSeries, IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<TimeSeriesCreate>> buildTimeSeries, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource timeSeries

Cognite timeseries resource

IEnumerable<string> externalIds

External Ids

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

Function that builds CogniteSdk TimeSeriesCreate objects

int chunkSize

Chunk size

int throttleSize

Throttle size

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

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

Get or create 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 using the chunking of items and throttling passed as parameters 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 static Task<CogniteResult<TimeSeries, TimeSeriesCreate>> GetOrCreateTimeSeriesAsync(this TimeSeriesResource timeSeries, IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<TimeSeriesCreate>>> buildTimeSeries, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource timeSeries

Cognite client

IEnumerable<string> externalIds

External Ids

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

Async function that builds CogniteSdk TimeSeriesCreate objects

int chunkSize

Chunk size

int throttleSize

Throttle size

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

GetTimeSeriesByIdsIgnoreErrors(TimeSeriesResource, IEnumerable<Identity>, int, int, CancellationToken)

Get the time series with the provided ids. Ignore any unknown ids

Declaration
public static Task<IEnumerable<TimeSeries>> GetTimeSeriesByIdsIgnoreErrors(this TimeSeriesResource timeSeries, IEnumerable<Identity> ids, int chunkSize, int throttleSize, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource timeSeries

A CogniteSdk TimeSeries resource

IEnumerable<Identity> ids

List of CogniteSdk.Identity objects

int chunkSize

Chunk size

int throttleSize

Throttle size

CancellationToken token

Cancellation token

Returns
Type Description
Task<IEnumerable<TimeSeries>>
| Edit this page View Source

UpdateAsync(TimeSeriesResource, IEnumerable<TimeSeriesUpdateItem>, int, int, RetryMode, SanitationMode, CancellationToken)

Update time series. If any items fail to be created due to missing asset, duplicated externalId, missing id, or missing dataSetId, they can be removed before retrying by setting retryMode Timeseries will be returned in the same order as given in items

Declaration
public static Task<CogniteResult<TimeSeries, TimeSeriesUpdateItem>> UpdateAsync(this TimeSeriesResource resource, IEnumerable<TimeSeriesUpdateItem> items, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource resource

CogniteSdk time series resource

IEnumerable<TimeSeriesUpdateItem> items

List of timeseries updates

int chunkSize

Maximum number of timeseries per request

int throttleSize

Maximum number of parallel requests

RetryMode retryMode

How to handle retries

SanitationMode sanitationMode

What kind of pre-request sanitation to perform

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

UpsertAsync(TimeSeriesResource, IEnumerable<TimeSeriesCreate>, int, int, 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 static Task<CogniteResult<TimeSeries, TimeSeriesCreate>> UpsertAsync(this TimeSeriesResource tss, IEnumerable<TimeSeriesCreate> upserts, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, UpsertParams? options, CancellationToken token)
Parameters
Type Name Description
TimeSeriesResource tss

TimeSeries resource

IEnumerable<TimeSeriesCreate> upserts

Assets to upsert

int chunkSize

Number of asset creates, retrieves or updates per request

int throttleSize

Maximum number of parallel requests

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

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX