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..08da47c 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"); @@ -119,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); } /// diff --git a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs index d01e712..83baf25 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").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).ConfigureAwait(false); + response.EnsureSuccessStatusCode(); + return await FindCurrentAsync().ConfigureAwait(false); + } } } 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" ],