From edfaf989f36bdade7858fe08c2daf3e50a53f117 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Thu, 15 Dec 2016 09:44:46 +1000 Subject: [PATCH 1/4] Dev version bump [Skip CI] --- src/Seq.Api/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Api/project.json b/src/Seq.Api/project.json index 2fb94bd..e704106 100644 --- a/src/Seq.Api/project.json +++ b/src/Seq.Api/project.json @@ -1,5 +1,5 @@ { - "version": "3.4.2-*", + "version": "3.4.3-*", "description": "Client library for the Seq HTTP API.", "authors": [ "Datalust", "Contributors" ], From ac35557795385edc564e46f87f272eea53e4ae4d Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 24 Jan 2017 07:58:37 +1000 Subject: [PATCH 2/4] Add LoginWindowsIntegratedAsync() to the Users resource --- example/SignalCopy/Program.cs | 1 - example/SignalCopy/Properties/launchSettings.json | 2 +- src/Seq.Api/Api/Client/SeqApiClient.cs | 4 +++- .../Api/ResourceGroups/UsersResourceGroup.cs | 13 +++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/example/SignalCopy/Program.cs b/example/SignalCopy/Program.cs index f77c169..b831266 100644 --- a/example/SignalCopy/Program.cs +++ b/example/SignalCopy/Program.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using DocoptNet; using Seq.Api; -using System.Linq; using Seq.Api.Model.Signals; using System.Collections.Generic; diff --git a/example/SignalCopy/Properties/launchSettings.json b/example/SignalCopy/Properties/launchSettings.json index f57dda9..16428f3 100644 --- a/example/SignalCopy/Properties/launchSettings.json +++ b/example/SignalCopy/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "SignalCopy": { "commandName": "Project", - "commandLineArgs": "http://localhost:5341 http://localhost:5342 --srckey=fSCcBOyOfttZ0kiZFgq" + "commandLineArgs": "http://localhost:5341 http://localhost:5342" } } } \ No newline at end of file diff --git a/src/Seq.Api/Api/Client/SeqApiClient.cs b/src/Seq.Api/Api/Client/SeqApiClient.cs index 30df9b7..82654bb 100644 --- a/src/Seq.Api/Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Api/Client/SeqApiClient.cs @@ -45,7 +45,7 @@ public SeqApiClient(string serverUrl, string apiKey = null) if (!string.IsNullOrEmpty(apiKey)) _apiKey = apiKey; - var handler = new HttpClientHandler { CookieContainer = _cookies }; + var handler = new HttpClientHandler { CookieContainer = _cookies, UseDefaultCredentials = true }; var baseAddress = serverUrl; if (!baseAddress.EndsWith("/")) @@ -56,6 +56,8 @@ public SeqApiClient(string serverUrl, string apiKey = null) public string ServerUrl { get; } + public HttpClient HttpClient => _httpClient; + public Task GetRootAsync() { return HttpGetAsync("api"); diff --git a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs index d01e712..5a3264b 100644 --- a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Threading.Tasks; using Seq.Api.Model.Users; +using System.Linq; +using Seq.Api.Client; namespace Seq.Api.ResourceGroups { @@ -65,5 +67,16 @@ public async Task GetSearchHistoryAsync(UserEntity entity) { return await Client.GetAsync(entity, "SearchHistory").ConfigureAwait(false); } + + public async Task LoginWindowsIntegratedAsync() + { + var providers = await GroupGetAsync("AuthenticationProviders"); + var provider = providers.Providers.SingleOrDefault(p => p.Name == "Integrated Windows Authentication"); + if (provider == null) + throw new SeqApiException("The Integrated Windows Authentication provider is not available."); + var response = await Client.HttpClient.GetAsync(provider.Url); + response.EnsureSuccessStatusCode(); + return await FindCurrentAsync(); + } } } From 7c7e248d28801fbadb1901e84bbd8ae9476b6fa1 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Fri, 27 Jan 2017 13:23:08 +1000 Subject: [PATCH 3/4] Missing .ConfigureAwait(false) --- src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs index 5a3264b..83baf25 100644 --- a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs @@ -70,13 +70,13 @@ public async Task GetSearchHistoryAsync(UserEntity entity) public async Task LoginWindowsIntegratedAsync() { - var providers = await GroupGetAsync("AuthenticationProviders"); + var providers = await GroupGetAsync("AuthenticationProviders").ConfigureAwait(false); var provider = providers.Providers.SingleOrDefault(p => p.Name == "Integrated Windows Authentication"); if (provider == null) throw new SeqApiException("The Integrated Windows Authentication provider is not available."); - var response = await Client.HttpClient.GetAsync(provider.Url); + var response = await Client.HttpClient.GetAsync(provider.Url).ConfigureAwait(false); response.EnsureSuccessStatusCode(); - return await FindCurrentAsync(); + return await FindCurrentAsync().ConfigureAwait(false); } } } From 46f63ea998d8e5caa984c8284a29dbd738448354 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 30 Jan 2017 08:40:44 +1000 Subject: [PATCH 4/4] Fixes Events.DeleteInSignalAsync() --- src/Seq.Api/Api/Client/SeqApiClient.cs | 8 ++++++++ src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs | 6 ++++++ src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Seq.Api/Api/Client/SeqApiClient.cs b/src/Seq.Api/Api/Client/SeqApiClient.cs index 82654bb..08da47c 100644 --- a/src/Seq.Api/Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Api/Client/SeqApiClient.cs @@ -121,6 +121,14 @@ public async Task DeleteAsync(ILinked entity, string link, TEntity cont new StreamReader(stream).ReadToEnd(); } + public async Task DeleteAsync(ILinked entity, string link, TEntity content, IDictionary parameters = null) + { + var linkUri = ResolveLink(entity, link, parameters); + var request = new HttpRequestMessage(HttpMethod.Delete, linkUri) { Content = MakeJsonContent(content) }; + var stream = await HttpSendAsync(request).ConfigureAwait(false); + return _serializer.Deserialize(new JsonTextReader(new StreamReader(stream))); + } + public async Task> StreamAsync(ILinked entity, string link, IDictionary parameters = null) { return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize(new JsonTextReader(reader))); diff --git a/src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs index 4555ef2..6616712 100644 --- a/src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs +++ b/src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs @@ -72,5 +72,11 @@ protected async Task GroupDeleteAsync(string link, TEntity content, IDi var group = await LoadGroupAsync().ConfigureAwait(false); await Client.DeleteAsync(group, link, content, parameters).ConfigureAwait(false); } + + protected async Task GroupDeleteAsync(string link, TEntity content, IDictionary parameters = null) + { + var group = await LoadGroupAsync().ConfigureAwait(false); + return await Client.DeleteAsync(group, link, content, parameters).ConfigureAwait(false); + } } } diff --git a/src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs index beb8ce5..8610b36 100644 --- a/src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs +++ b/src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs @@ -155,7 +155,7 @@ public async Task DeleteInSignalAsync( if (toDateUtc != null) { parameters.Add("toDateUtc", toDateUtc.Value); } var body = signal ?? new SignalEntity(); - return await GroupPostAsync("DeleteInSignal", body, parameters).ConfigureAwait(false); + return await GroupDeleteAsync("DeleteInSignal", body, parameters).ConfigureAwait(false); } ///