Show / Hide Table of Contents

Class SequenceExtensions

Extensions to sequences.

Inheritance
object
SequenceExtensions
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 SequenceExtensions

Methods

| Edit this page View Source

EnsureExistsAsync(SequencesResource, IEnumerable<SequenceCreate>, int, int, RetryMode, SanitationMode, CancellationToken)

Ensures that all sequences in sequencesToEnsure exist in CDF. Tries to create the sequences 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, issues with the columns, or missing dataSetId, they can be removed before retrying by setting retryMode Sequences will be returned in the same order as given in sequencesToEnsure

Declaration
public static Task<CogniteResult<Sequence, SequenceCreate>> EnsureExistsAsync(this SequencesResource sequences, IEnumerable<SequenceCreate> sequencesToEnsure, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
SequencesResource sequences

Cognite client

IEnumerable<SequenceCreate> sequencesToEnsure

List of CogniteSdk SequenceCreate 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 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

GetByIdsIgnoreErrors(SequencesResource, IEnumerable<Identity>, int, int, CancellationToken)

Get the sequences with the provided ids. Ignore any unknown ids

Declaration
public static Task<IEnumerable<Sequence>> GetByIdsIgnoreErrors(this SequencesResource sequences, IEnumerable<Identity> ids, int chunkSize, int throttleSize, CancellationToken token)
Parameters
Type Name Description
SequencesResource sequences

A CogniteSdk Sequences 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<Sequence>>
| Edit this page View Source

GetOrCreateAsync(SequencesResource, IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<SequenceCreate>>, int, int, RetryMode, SanitationMode, CancellationToken)

Get or create the sequences with the provided externalIds. If one or more do not exist, use the buildSequences function to construct the missing sequence 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, issues with the columns, or missing dataSetId, they can be removed before retrying by setting retryMode

Declaration
public static Task<CogniteResult<Sequence, SequenceCreate>> GetOrCreateAsync(this SequencesResource sequences, IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<SequenceCreate>> buildSequences, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
SequencesResource sequences

Cognite sequences resource

IEnumerable<string> externalIds

External Ids

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

Function that builds CogniteSdk SequenceCreate 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 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

GetOrCreateAsync(SequencesResource, IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<SequenceCreate>>>, int, int, RetryMode, SanitationMode, CancellationToken)

Get or create the sequences with the provided externalIds. If one or more do not exist, use the buildSequences function to construct the missing sequence 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, issues with the columns, or missing dataSetId, they can be removed before retrying by setting retryMode

Declaration
public static Task<CogniteResult<Sequence, SequenceCreate>> GetOrCreateAsync(this SequencesResource sequences, IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<SequenceCreate>>> buildSequences, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
SequencesResource sequences

Cognite client

IEnumerable<string> externalIds

External Ids

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

Async function that builds CogniteSdk SequenceCreate 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 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

InsertAsync(SequencesResource, IEnumerable<SequenceDataCreate>, int, int, int, int, RetryMode, SanitationMode, CancellationToken)

Insert sequence rows into given list of sequences. Chunks by both number of sequences per request, and number of rows per sequence. Optionally sanitizes the request, and handles errors that occur while running.

Declaration
public static Task<CogniteResult<SequenceRowError>> InsertAsync(this SequencesResource sequences, IEnumerable<SequenceDataCreate> toCreate, int keyChunkSize, int valueChunkSize, int sequencesChunk, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
SequencesResource sequences

CogniteSdk sequence resource object

IEnumerable<SequenceDataCreate> toCreate

List of sequences and rows to create

int keyChunkSize

Maximum number of sequences in each request

int valueChunkSize

Maximum number of sequence rows per sequence

int sequencesChunk

Maximum number of sequences to read at a time if reading to handle errors

int throttleSize

Maximum number of parallel requests

RetryMode retryMode

How to handle errors

SanitationMode sanitationMode

How to sanitize the request before sending

CancellationToken token

Cancellation token

Returns
Type Description
Task<CogniteResult<SequenceRowError>>

Result containing optional errors if something went wrong

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