Class ResultHandlers
Class containing static methods to parse errors from the SDK and clean request objects
Inherited Members
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public static class ResultHandlers
Methods
| Edit this page View SourceCleanFromError(CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>)
Clean a list of identity/datapoint pairs based on CogniteError
Declaration
public static IDictionary<Identity, IEnumerable<Datapoint>> CleanFromError(CogniteError<DataPointInsertError> error, IDictionary<Identity, IEnumerable<Datapoint>> datapoints)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<DataPointInsertError> | error | Error to clean from |
| IDictionary<Identity, IEnumerable<Datapoint>> | datapoints | Datapoints to remove |
Returns
| Type | Description |
|---|---|
| IDictionary<Identity, IEnumerable<Datapoint>> | A modified version of |
CleanFromError(CogniteError<SequenceRowError>, IEnumerable<SequenceDataCreate>)
Clean list of SequenceDataCreates based on error.
Declaration
public static IEnumerable<SequenceDataCreate> CleanFromError(CogniteError<SequenceRowError> error, IEnumerable<SequenceDataCreate> creates)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<SequenceRowError> | error | Error to clean from |
| IEnumerable<SequenceDataCreate> | creates | Sequence data creates to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<SequenceDataCreate> | Sequences data creates that did not cause |
CleanFromError(CogniteError<AssetCreate>, IEnumerable<AssetCreate>)
Clean list of AssetCreate objects based on CogniteError object
Declaration
public static IEnumerable<AssetCreate> CleanFromError(CogniteError<AssetCreate> error, IEnumerable<AssetCreate> assets)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<AssetCreate> | error | Error that occured with a previous push |
| IEnumerable<AssetCreate> | assets | Assets to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<AssetCreate> | Assets that are not affected by the error |
CleanFromError(CogniteError<AssetUpdateItem>, IEnumerable<AssetUpdateItem>)
Clean list of AssetUpdate objects based on CogniteError object
Declaration
public static IEnumerable<AssetUpdateItem> CleanFromError(CogniteError<AssetUpdateItem> error, IEnumerable<AssetUpdateItem> items)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<AssetUpdateItem> | error | Error that occured with a previous push |
| IEnumerable<AssetUpdateItem> | items | Assets to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<AssetUpdateItem> | Assets that are not affected by the error |
CleanFromError(CogniteError<EventCreate>, IEnumerable<EventCreate>)
Clean list of EventCreate objects based on CogniteError
Declaration
public static IEnumerable<EventCreate> CleanFromError(CogniteError<EventCreate> error, IEnumerable<EventCreate> events)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<EventCreate> | error | Error that occurred with a previous push |
| IEnumerable<EventCreate> | events | Events to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<EventCreate> | Events that are not affected by the error |
CleanFromError(CogniteError<SequenceCreate>, IEnumerable<SequenceCreate>)
Clean list of SequenceCreate objects based on CogniteError
Declaration
public static IEnumerable<SequenceCreate> CleanFromError(CogniteError<SequenceCreate> error, IEnumerable<SequenceCreate> sequences)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<SequenceCreate> | error | Error that occured with a previous push |
| IEnumerable<SequenceCreate> | sequences | Sequences to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<SequenceCreate> | Sequences that are not affected by the error |
CleanFromError(CogniteError<TimeSeriesCreate>, IEnumerable<TimeSeriesCreate>)
Clean list of TimeSeriesCreate objects based on CogniteError
Declaration
public static IEnumerable<TimeSeriesCreate> CleanFromError(CogniteError<TimeSeriesCreate> error, IEnumerable<TimeSeriesCreate> timeseries)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<TimeSeriesCreate> | error | Error that occured with a previous push |
| IEnumerable<TimeSeriesCreate> | timeseries | Timeseries to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<TimeSeriesCreate> | TimeSeries that are not affected by the error |
CleanFromError(CogniteError<TimeSeriesUpdateItem>, IEnumerable<TimeSeriesUpdateItem>)
Clean list of TimeSeriesUpdateItem objects based on CogniteError
Declaration
public static IEnumerable<TimeSeriesUpdateItem> CleanFromError(CogniteError<TimeSeriesUpdateItem> error, IEnumerable<TimeSeriesUpdateItem> items)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<TimeSeriesUpdateItem> | error | Error that occured with a previous push |
| IEnumerable<TimeSeriesUpdateItem> | items | Timeseries updates to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<TimeSeriesUpdateItem> | TimeSeries updates that are not affected by the error |
CleanFromError<T>(CogniteError<SourcedNodeWrite<T>>, IEnumerable<SourcedNodeWrite<T>>)
Clean list of SourceNodeWrite objects based on CogniteError
Declaration
public static IEnumerable<SourcedNodeWrite<T>> CleanFromError<T>(CogniteError<SourcedNodeWrite<T>> error, IEnumerable<SourcedNodeWrite<T>> timeseries)
Parameters
| Type | Name | Description |
|---|---|---|
| CogniteError<SourcedNodeWrite<T>> | error | Error that occured with a previous push |
| IEnumerable<SourcedNodeWrite<T>> | timeseries | Nodes to clean |
Returns
| Type | Description |
|---|---|
| IEnumerable<SourcedNodeWrite<T>> | Nodes that are not affected by the error |
Type Parameters
| Name | Description |
|---|---|
| T |
CompleteAssetError(AssetsResource, CogniteError, IEnumerable<AssetCreate>, int, int, CancellationToken)
Fetch missing parents for an asset create that failed due to missing parent external ids.
Declaration
public static Task CompleteAssetError(AssetsResource resource, CogniteError error, IEnumerable<AssetCreate> assets, int assetChunkSize, int assetThrottleSize, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetsResource | resource | CogniteSdk assets resource |
| CogniteError | error | Incomplete error |
| IEnumerable<AssetCreate> | assets | List of assets to check |
| int | assetChunkSize | Chunk size for reading assets |
| int | assetThrottleSize | Throttle size for reading assets |
| CancellationToken | token | Cancellation token |
Returns
| Type | Description |
|---|---|
| Task |
ContainsIdentity(HashSet<Identity>, InstanceIdentifier)
Utility method for checking if set of identities contains instance id.
Declaration
public static bool ContainsIdentity(this HashSet<Identity> set, InstanceIdentifier idt)
Parameters
| Type | Name | Description |
|---|---|---|
| HashSet<Identity> | set | Set of identities |
| InstanceIdentifier | idt | IntanceId to test |
Returns
| Type | Description |
|---|---|
| bool | True if instance id is non-null and set contains it, false otherwise |
ContainsIdentity(HashSet<Identity>, long?)
Utility method for checking if set of identities contains internal id.
Declaration
public static bool ContainsIdentity(this HashSet<Identity> set, long? idt)
Parameters
| Type | Name | Description |
|---|---|---|
| HashSet<Identity> | set | Set of identities |
| long? | idt | ExternalId to test |
Returns
| Type | Description |
|---|---|
| bool | True if internal id is non-null and set contains it, false otherwise |
ContainsIdentity(HashSet<Identity>, string?)
Utility method for checking if set of identities contains external id.
Declaration
public static bool ContainsIdentity(this HashSet<Identity> set, string? idt)
Parameters
| Type | Name | Description |
|---|---|---|
| HashSet<Identity> | set | Set of identities |
| string | idt | ExternalId to test |
Returns
| Type | Description |
|---|---|
| bool | True if externalId is non-null and set contains it, false otherwise |
ParseException<TError>(Exception, RequestType)
Parse exception into CogniteError which describes the error in detail.
Declaration
public static CogniteError<TError> ParseException<TError>(Exception ex, RequestType type)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | Exception to parse |
| RequestType | type | Request type |
Returns
| Type | Description |
|---|---|
| CogniteError<TError> | CogniteError representation of the exception |
Type Parameters
| Name | Description |
|---|---|
| TError |
ParseSimpleError<TError>(Exception, IEnumerable<Identity>?, IEnumerable<TError>?)
Create a CogniteError from exception thrown when doing some simple operation to CDF. Just creates a fatal error based on the exception.
Declaration
public static CogniteError<TError> ParseSimpleError<TError>(Exception ex, IEnumerable<Identity>? failed, IEnumerable<TError>? skipped)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | Exception thrown by method |
| IEnumerable<Identity> | failed | Items that failed, optional |
| IEnumerable<TError> | skipped | Items that were skipped, optional |
Returns
| Type | Description |
|---|---|
| CogniteError<TError> |
Type Parameters
| Name | Description |
|---|---|
| TError | Errortype on result |
VerifyAssetUpdateParents(AssetsResource, IEnumerable<AssetUpdateItem>, int, int, CancellationToken)
Ensure that the assets have legal parents, and are not being moved between root hierarchies.
Declaration
public static Task<IEnumerable<CogniteError<AssetUpdateItem>>> VerifyAssetUpdateParents(AssetsResource resource, IEnumerable<AssetUpdateItem> items, int assetChunkSize, int assetThrottleSize, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetsResource | resource | CogniteSdk assets resource |
| IEnumerable<AssetUpdateItem> | items | Asset update items to check |
| int | assetChunkSize | Chunk size for reading assets |
| int | assetThrottleSize | Throttle size for reading assets |
| CancellationToken | token | Cancellation token |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<CogniteError<AssetUpdateItem>>> | A list of errors if anything failed |
VerifyDatapointsFromCDF(CoreTimeSeriesResource<CogniteTimeSeriesBase>, CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>, int, int, CancellationToken)
Ensure that the given list of datapoints have timeseries with matching types in CDF. Does not report missing timeseries, but will skip them. Typically this will be called after trying to insert to CDF, for efficiency.
Declaration
public static Task<(CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>)> VerifyDatapointsFromCDF(CoreTimeSeriesResource<CogniteTimeSeriesBase> resource, CogniteError<DataPointInsertError> error, IDictionary<Identity, IEnumerable<Datapoint>> datapoints, int timeseriesChunkSize, int timeseriesThrottleSize, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| CoreTimeSeriesResource<CogniteTimeSeriesBase> | resource | CogniteSdk TimeSeries resource |
| CogniteError<DataPointInsertError> | error | Cognite error, optional |
| IDictionary<Identity, IEnumerable<Datapoint>> | datapoints | Datapoints to verify |
| int | timeseriesChunkSize | Max number of timeseries to read at a time |
| int | timeseriesThrottleSize | Maximum number of parallel requests for timeseries |
| CancellationToken | token | Cancellation token |
Returns
| Type | Description |
|---|---|
| Task<(CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>)> | Verified datapoint insertions and optional error |
VerifyDatapointsFromCDF(TimeSeriesResource, CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>, int, int, CancellationToken)
Ensure that the given list of datapoints have timeseries with matching types in CDF. Does not report missing timeseries, but will skip them. Typically this will be called after trying to insert to CDF, for efficiency.
Declaration
public static Task<(CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>)> VerifyDatapointsFromCDF(TimeSeriesResource resource, CogniteError<DataPointInsertError> error, IDictionary<Identity, IEnumerable<Datapoint>> datapoints, int timeseriesChunkSize, int timeseriesThrottleSize, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSeriesResource | resource | CogniteSdk TimeSeries resource |
| CogniteError<DataPointInsertError> | error | Cognite error, optional |
| IDictionary<Identity, IEnumerable<Datapoint>> | datapoints | Datapoints to verify |
| int | timeseriesChunkSize | Max number of timeseries to read at a time |
| int | timeseriesThrottleSize | Maximum number of parallel requests for timeseries |
| CancellationToken | token | Cancellation token |
Returns
| Type | Description |
|---|---|
| Task<(CogniteError<DataPointInsertError>, IDictionary<Identity, IEnumerable<Datapoint>>)> | Verified datapoint insertions and optional error |
VerifySequencesFromCDF(SequencesResource, IEnumerable<SequenceDataCreate>, int, int, CancellationToken)
Ensure that the list of sequence row creates correctly match the corresponding sequences in CDF, checks both missing columns and mismatched data types.
Declaration
public static Task<IEnumerable<CogniteError<SequenceRowError>>> VerifySequencesFromCDF(SequencesResource resource, IEnumerable<SequenceDataCreate> creates, int sequencesChunkSize, int sequencesThrottleSize, CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| SequencesResource | resource | CogniteSdk Sequences resource |
| IEnumerable<SequenceDataCreate> | creates | SequenceDataCreates to check |
| int | sequencesChunkSize | Chunk size for reading sequences from CDF |
| int | sequencesThrottleSize | Number of parallel requests to read sequences from CDF |
| CancellationToken | token | Cancellation token |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<CogniteError<SequenceRowError>>> | Up to two CogniteError containing data about failed sequences |