From 45a836874235d44f303d1fef03d33e596f309e6a Mon Sep 17 00:00:00 2001 From: Einar Omang Date: Tue, 29 Oct 2024 12:31:27 +0100 Subject: [PATCH] Update to latest API shape --- CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs | 6 +----- CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs | 13 ++----------- CogniteSdk/src/Resources/Alpha/LogAnalytics.cs | 13 +++++++------ Oryx.Cognite/src/Alpha/LogAnalytics.fs | 14 +++++++------- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs b/CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs index 3a9d7045..3676d933 100644 --- a/CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs +++ b/CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using CogniteSdk.Beta.DataModels; +using CogniteSdk.DataModels; namespace CogniteSdk.Alpha { @@ -28,9 +28,5 @@ public class LogItem /// public class LogIngest : ItemsWithoutCursor { - /// - /// Name of the stream where the logs are located. - /// - public string Stream { get; set; } } } \ No newline at end of file diff --git a/CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs b/CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs index 2824c12c..2c03b37a 100644 --- a/CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs +++ b/CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Text.Json.Serialization; -using CogniteSdk.Beta.DataModels; +using CogniteSdk.DataModels; namespace CogniteSdk.Alpha { @@ -96,11 +96,6 @@ public class LogRetrieve /// public IEnumerable Sources { get; set; } /// - /// Optional attribute to extend the filter with full text search capabilities - /// for a single field in the list of log properties with OR logic. - /// - public LogSearch Search { get; set; } - /// /// A filter Domain Specific Language (DSL) used to create advanced filter queries. /// /// Note that some filter types are not supported with ILA, see API docs. @@ -126,10 +121,6 @@ public class LogRetrieve /// public class LogSync { - /// - /// Name of the stream where logs are located, required. - /// - public string Stream { get; set; } /// /// List of containers and the properties that should be selected. /// @@ -145,7 +136,7 @@ public class LogSync /// /// A cursor returned from the previous sync request. /// - public string Cursors { get; set; } + public string Cursor { get; set; } /// /// Maximum number of results to return. /// diff --git a/CogniteSdk/src/Resources/Alpha/LogAnalytics.cs b/CogniteSdk/src/Resources/Alpha/LogAnalytics.cs index 3154d11a..a07d28cc 100644 --- a/CogniteSdk/src/Resources/Alpha/LogAnalytics.cs +++ b/CogniteSdk/src/Resources/Alpha/LogAnalytics.cs @@ -33,9 +33,8 @@ public async Task IngestAsync(string stream, IEnumerable logs, Cancella throw new ArgumentNullException(nameof(stream)); } - var req = Oryx.Cognite.Alpha.LogAnalytics.ingest(new LogIngest + var req = Oryx.Cognite.Alpha.LogAnalytics.ingest(stream, new LogIngest { - Stream = stream, Items = logs, }, GetContext(token)); await RunAsync(req).ConfigureAwait(false); @@ -45,17 +44,18 @@ public async Task IngestAsync(string stream, IEnumerable logs, Cancella /// Retrieve a list of logs. /// /// Type of properties in the retrieved logs. + /// Stream to ingest logs into. /// Log retrieval request. /// Optional cancellation token. /// Retrieved logs. - public async Task>> RetrieveAsync(LogRetrieve request, CancellationToken token = default) + public async Task>> RetrieveAsync(string stream, LogRetrieve request, CancellationToken token = default) { if (request is null) { throw new ArgumentNullException(nameof(request)); } - var req = Oryx.Cognite.Alpha.LogAnalytics.retrieve(request, GetContext(token)); + var req = Oryx.Cognite.Alpha.LogAnalytics.retrieve(stream, request, GetContext(token)); return await RunAsync(req).ConfigureAwait(false); } @@ -63,17 +63,18 @@ public async Task>> RetrieveAsync(LogRetrieve request, Can /// Synchronizes updates to logs. This endpoint will always return a cursor. /// /// Type of properties in the retrieved logs. + /// Stream to ingest logs into. /// Log retreival request. /// Optional cancellation token. /// Sync response. - public async Task> SyncAsync(LogSync request, CancellationToken token = default) + public async Task> SyncAsync(string stream, LogSync request, CancellationToken token = default) { if (request is null) { throw new ArgumentNullException(nameof(request)); } - var req = Oryx.Cognite.Alpha.LogAnalytics.sync(request, GetContext(token)); + var req = Oryx.Cognite.Alpha.LogAnalytics.sync(stream, request, GetContext(token)); return await RunAsync(req).ConfigureAwait(false); } } diff --git a/Oryx.Cognite/src/Alpha/LogAnalytics.fs b/Oryx.Cognite/src/Alpha/LogAnalytics.fs index 089d7619..e2712706 100644 --- a/Oryx.Cognite/src/Alpha/LogAnalytics.fs +++ b/Oryx.Cognite/src/Alpha/LogAnalytics.fs @@ -12,27 +12,27 @@ open CogniteSdk.Alpha [] module LogAnalytics = [] - let Url = "/logs" + let Url = "/streams" - let ingest (items: LogIngest) (source: HttpHandler) : HttpHandler = + let ingest (stream: string) (items: LogIngest) (source: HttpHandler) : HttpHandler = source |> withLogMessage "loganalytics:ingest" |> withAlphaHeader - |> postV10 items Url + |> postV10 items (Url +/ stream +/ "records") - let retrieve<'T> (request: LogRetrieve) (source: HttpHandler) : HttpHandler seq> = + let retrieve<'T> (stream: string) (request: LogRetrieve) (source: HttpHandler) : HttpHandler seq> = http { let! ret = source |> withLogMessage "loganalytics:retrieve" |> withCompletion System.Net.Http.HttpCompletionOption.ResponseHeadersRead - |> postV10<_, CogniteSdk.ItemsWithoutCursor<_>> request (Url +/ "list") + |> postV10<_, CogniteSdk.ItemsWithoutCursor<_>> request (Url +/ stream +/ "records/filter") return ret.Items } - let sync<'T> (request: LogSync) (source: HttpHandler) : HttpHandler> = + let sync<'T> (stream: string) (request: LogSync) (source: HttpHandler) : HttpHandler> = source |> withLogMessage "loganalytics:sync" |> withCompletion System.Net.Http.HttpCompletionOption.ResponseHeadersRead - |> postV10 request (Url +/ "sync") + |> postV10 request (Url +/ stream +/ "records/sync")