Skip to content

Commit

Permalink
Merge pull request #30 from datalust/dev
Browse files Browse the repository at this point in the history
3.4.3 Release
  • Loading branch information
nblumhardt authored Feb 7, 2017
2 parents 5c19bc0 + f54a9e5 commit cb81556
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
1 change: 0 additions & 1 deletion example/SignalCopy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion example/SignalCopy/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"SignalCopy": {
"commandName": "Project",
"commandLineArgs": "http://localhost:5341 http://localhost:5342 --srckey=fSCcBOyOfttZ0kiZFgq"
"commandLineArgs": "http://localhost:5341 http://localhost:5342"
}
}
}
12 changes: 11 additions & 1 deletion src/Seq.Api/Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"))
Expand All @@ -56,6 +56,8 @@ public SeqApiClient(string serverUrl, string apiKey = null)

public string ServerUrl { get; }

public HttpClient HttpClient => _httpClient;

public Task<RootEntity> GetRootAsync()
{
return HttpGetAsync<RootEntity>("api");
Expand Down Expand Up @@ -119,6 +121,14 @@ public async Task DeleteAsync<TEntity>(ILinked entity, string link, TEntity cont
new StreamReader(stream).ReadToEnd();
}

public async Task<TResponse> DeleteAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> 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<TResponse>(new JsonTextReader(new StreamReader(stream)));
}

public async Task<ObservableStream<TEntity>> StreamAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null)
{
return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize<TEntity>(new JsonTextReader(reader)));
Expand Down
6 changes: 6 additions & 0 deletions src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ protected async Task GroupDeleteAsync<TEntity>(string link, TEntity content, IDi
var group = await LoadGroupAsync().ConfigureAwait(false);
await Client.DeleteAsync(group, link, content, parameters).ConfigureAwait(false);
}

protected async Task<TResponse> GroupDeleteAsync<TEntity, TResponse>(string link, TEntity content, IDictionary<string, object> parameters = null)
{
var group = await LoadGroupAsync().ConfigureAwait(false);
return await Client.DeleteAsync<TEntity, TResponse>(group, link, content, parameters).ConfigureAwait(false);
}
}
}
2 changes: 1 addition & 1 deletion src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task<ResultSetPart> DeleteInSignalAsync(
if (toDateUtc != null) { parameters.Add("toDateUtc", toDateUtc.Value); }

var body = signal ?? new SignalEntity();
return await GroupPostAsync<SignalEntity, ResultSetPart>("DeleteInSignal", body, parameters).ConfigureAwait(false);
return await GroupDeleteAsync<SignalEntity, ResultSetPart>("DeleteInSignal", body, parameters).ConfigureAwait(false);
}

/// <summary>
Expand Down
13 changes: 13 additions & 0 deletions src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -65,5 +67,16 @@ public async Task<SearchHistoryEntity> GetSearchHistoryAsync(UserEntity entity)
{
return await Client.GetAsync<SearchHistoryEntity>(entity, "SearchHistory").ConfigureAwait(false);
}

public async Task<UserEntity> LoginWindowsIntegratedAsync()
{
var providers = await GroupGetAsync<AuthProvidersPart>("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);
}
}
}
2 changes: 1 addition & 1 deletion src/Seq.Api/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.2-*",
"version": "3.4.3-*",

"description": "Client library for the Seq HTTP API.",
"authors": [ "Datalust", "Contributors" ],
Expand Down

0 comments on commit cb81556

Please sign in to comment.