Skip to content

Commit

Permalink
Update to latest API shape
Browse files Browse the repository at this point in the history
  • Loading branch information
einarmo committed Oct 29, 2024
1 parent a797f7a commit 45a8368
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
6 changes: 1 addition & 5 deletions CogniteSdk.Types/Alpha/LogAnalytics/LogIngest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using CogniteSdk.Beta.DataModels;
using CogniteSdk.DataModels;

namespace CogniteSdk.Alpha
{
Expand Down Expand Up @@ -28,9 +28,5 @@ public class LogItem
/// </summary>
public class LogIngest : ItemsWithoutCursor<LogItem>
{
/// <summary>
/// Name of the stream where the logs are located.
/// </summary>
public string Stream { get; set; }
}
}
13 changes: 2 additions & 11 deletions CogniteSdk.Types/Alpha/LogAnalytics/LogRetrieve.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using CogniteSdk.Beta.DataModels;
using CogniteSdk.DataModels;

namespace CogniteSdk.Alpha
{
Expand Down Expand Up @@ -96,11 +96,6 @@ public class LogRetrieve
/// </summary>
public IEnumerable<LogSource> Sources { get; set; }
/// <summary>
/// Optional attribute to extend the filter with full text search capabilities
/// for a single field in the list of log properties with OR logic.
/// </summary>
public LogSearch Search { get; set; }
/// <summary>
/// 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.
Expand All @@ -126,10 +121,6 @@ public class LogRetrieve
/// </summary>
public class LogSync
{
/// <summary>
/// Name of the stream where logs are located, required.
/// </summary>
public string Stream { get; set; }
/// <summary>
/// List of containers and the properties that should be selected.
///
Expand All @@ -145,7 +136,7 @@ public class LogSync
/// <summary>
/// A cursor returned from the previous sync request.
/// </summary>
public string Cursors { get; set; }
public string Cursor { get; set; }
/// <summary>
/// Maximum number of results to return.
/// </summary>
Expand Down
13 changes: 7 additions & 6 deletions CogniteSdk/src/Resources/Alpha/LogAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public async Task IngestAsync(string stream, IEnumerable<LogItem> 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);
Expand All @@ -45,35 +44,37 @@ public async Task IngestAsync(string stream, IEnumerable<LogItem> logs, Cancella
/// Retrieve a list of logs.
/// </summary>
/// <typeparam name="T">Type of properties in the retrieved logs.</typeparam>
/// <param name="stream">Stream to ingest logs into.</param>
/// <param name="request">Log retrieval request.</param>
/// <param name="token">Optional cancellation token.</param>
/// <returns>Retrieved logs.</returns>
public async Task<IEnumerable<Log<T>>> RetrieveAsync<T>(LogRetrieve request, CancellationToken token = default)
public async Task<IEnumerable<Log<T>>> RetrieveAsync<T>(string stream, LogRetrieve request, CancellationToken token = default)
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}

var req = Oryx.Cognite.Alpha.LogAnalytics.retrieve<T>(request, GetContext(token));
var req = Oryx.Cognite.Alpha.LogAnalytics.retrieve<T>(stream, request, GetContext(token));
return await RunAsync(req).ConfigureAwait(false);
}

/// <summary>
/// Synchronizes updates to logs. This endpoint will always return a cursor.
/// </summary>
/// <typeparam name="T">Type of properties in the retrieved logs.</typeparam>
/// <param name="stream">Stream to ingest logs into.</param>
/// <param name="request">Log retreival request.</param>
/// <param name="token">Optional cancellation token.</param>
/// <returns>Sync response.</returns>
public async Task<LogSyncResponse<T>> SyncAsync<T>(LogSync request, CancellationToken token = default)
public async Task<LogSyncResponse<T>> SyncAsync<T>(string stream, LogSync request, CancellationToken token = default)
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}

var req = Oryx.Cognite.Alpha.LogAnalytics.sync<T>(request, GetContext(token));
var req = Oryx.Cognite.Alpha.LogAnalytics.sync<T>(stream, request, GetContext(token));
return await RunAsync(req).ConfigureAwait(false);
}
}
Expand Down
14 changes: 7 additions & 7 deletions Oryx.Cognite/src/Alpha/LogAnalytics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ open CogniteSdk.Alpha
[<RequireQualifiedAccess>]
module LogAnalytics =
[<Literal>]
let Url = "/logs"
let Url = "/streams"

let ingest (items: LogIngest) (source: HttpHandler<unit>) : HttpHandler<CogniteSdk.EmptyResponse> =
let ingest (stream: string) (items: LogIngest) (source: HttpHandler<unit>) : HttpHandler<CogniteSdk.EmptyResponse> =
source
|> withLogMessage "loganalytics:ingest"
|> withAlphaHeader
|> postV10 items Url
|> postV10 items (Url +/ stream +/ "records")

let retrieve<'T> (request: LogRetrieve) (source: HttpHandler<unit>) : HttpHandler<Log<'T> seq> =
let retrieve<'T> (stream: string) (request: LogRetrieve) (source: HttpHandler<unit>) : HttpHandler<Log<'T> 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<unit>) : HttpHandler<LogSyncResponse<'T>> =
let sync<'T> (stream: string) (request: LogSync) (source: HttpHandler<unit>) : HttpHandler<LogSyncResponse<'T>> =
source
|> withLogMessage "loganalytics:sync"
|> withCompletion System.Net.Http.HttpCompletionOption.ResponseHeadersRead
|> postV10 request (Url +/ "sync")
|> postV10 request (Url +/ stream +/ "records/sync")

0 comments on commit 45a8368

Please sign in to comment.