Show / Hide Table of Contents

Class EventExtensions

Extension utility methods for CogniteSdk Client.

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

Methods

| Edit this page View Source

EnsureExistsAsync(EventsResource, IEnumerable<EventCreate>, int, int, 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 a handled error. 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 static Task<CogniteResult<Event, EventCreate>> EnsureExistsAsync(this EventsResource resource, IEnumerable<EventCreate> events, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
EventsResource resource

Cognite events resource

IEnumerable<EventCreate> events

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

GetOrCreateAsync(EventsResource, IEnumerable<string>, Func<IEnumerable<string>, IEnumerable<EventCreate>>, int, int, RetryMode, SanitationMode, CancellationToken)

Get or create 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 using the chunking of items and throttling passed as parameters 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 static Task<CogniteResult<Event, EventCreate>> GetOrCreateAsync(this EventsResource resource, IEnumerable<string> externalIds, Func<IEnumerable<string>, IEnumerable<EventCreate>> buildEvents, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
EventsResource resource

Cognite events resource

IEnumerable<string> externalIds

External Ids

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

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

GetOrCreateAsync(EventsResource, IEnumerable<string>, Func<IEnumerable<string>, Task<IEnumerable<EventCreate>>>, int, int, RetryMode, SanitationMode, CancellationToken)

Get or create 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 using the chunking of items and throttling passed as parameters. 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 static Task<CogniteResult<Event, EventCreate>> GetOrCreateAsync(this EventsResource resource, IEnumerable<string> externalIds, Func<IEnumerable<string>, Task<IEnumerable<EventCreate>>> buildEvents, int chunkSize, int throttleSize, RetryMode retryMode, SanitationMode sanitationMode, CancellationToken token)
Parameters
Type Name Description
EventsResource resource

Cognite events resource

IEnumerable<string> externalIds

External Ids

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

Async function that builds CogniteSdk EventCreate 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 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
In this article
Back to top Generated by DocFX