Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Bug Fixes
1. [#106](https://github.com/influxdata/influxdb-client-csharp/pull/106): Fixed serialization of `\n`, `\r` and `\t` to Line Protocol, `=` is valid sign for measurement name
1. [#108](https://github.com/influxdata/influxdb-client-csharp/issues/108): Replaced useless .ContinueWith in Api by direct call

## 1.9.0 [2020-06-19]

Expand Down
4 changes: 2 additions & 2 deletions Client.Legacy/FluxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ public async Task<string> VersionAsync()
{
try
{
var response = ExecuteAsync(PingRequest());
var response = await ExecuteAsync(PingRequest());

return await response.ContinueWith(t => GetVersion(t.Result));
return GetVersion(response);
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions Client.Test/ItBucketsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void CloneBucketNotFound()
var ioe = Assert.ThrowsAsync<AggregateException>(async () =>
await _bucketsApi.CloneBucketAsync(GenerateName("bucket"), "020f755c3c082000"));

Assert.AreEqual(typeof(HttpException), ioe.InnerException.InnerException.GetType());
Assert.AreEqual("bucket not found", ioe.InnerException.InnerException.Message);
Assert.AreEqual(typeof(HttpException), ioe.InnerException?.GetType());
Assert.AreEqual("bucket not found", ioe.InnerException?.Message);
}

[Test]
Expand Down
16 changes: 8 additions & 8 deletions Client.Test/ItLabelsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void CloneLabelNotFound()
Assert.ThrowsAsync<AggregateException>(async () => await _labelsApi.CloneLabelAsync(GenerateName("bucket"), "020f755c3c082000"));

Assert.IsNotNull(exception);
Assert.AreEqual(typeof(HttpException), exception.InnerException.InnerException.GetType());
Assert.AreEqual("label not found", exception.InnerException.InnerException.Message);
Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType());
Assert.AreEqual("label not found", exception.InnerException.Message);
}

[Test]
Expand Down Expand Up @@ -99,11 +99,11 @@ public async Task DeleteLabel()
// delete user
await _labelsApi.DeleteLabelAsync(createdLabel);

var exception = Assert.ThrowsAsync<AggregateException>(async () => await _labelsApi.FindLabelByIdAsync(createdLabel.Id));
var exception = Assert.ThrowsAsync<HttpException>(async () => await _labelsApi.FindLabelByIdAsync(createdLabel.Id));

Assert.IsNotNull(exception);
Assert.AreEqual("label not found", exception.InnerException.Message);
Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType());
Assert.AreEqual("label not found", exception.Message);
Assert.AreEqual(typeof(HttpException), exception.GetType());
}

[Test]
Expand All @@ -122,11 +122,11 @@ public async Task FindLabelById()
[Test]
public void FindLabelByIdNull()
{
var exception = Assert.ThrowsAsync<AggregateException>(async () => await _labelsApi.FindLabelByIdAsync("020f755c3c082000"));
var exception = Assert.ThrowsAsync<HttpException>(async () => await _labelsApi.FindLabelByIdAsync("020f755c3c082000"));

Assert.IsNotNull(exception);
Assert.AreEqual("label not found", exception.InnerException.Message);
Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType());
Assert.AreEqual("label not found", exception.Message);
Assert.AreEqual(typeof(HttpException), exception.GetType());
}

[Test]
Expand Down
10 changes: 5 additions & 5 deletions Client.Test/ItNotificationEndpointsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,27 +431,27 @@ public void CloneNotFound()
var ioe = Assert.ThrowsAsync<AggregateException>(async () => await _notificationEndpointsApi
.CloneSlackEndpointAsync("not-found-cloned", "token", "020f755c3c082000"));

Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message);
Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message);

ioe = Assert.ThrowsAsync<AggregateException>(async () => await _notificationEndpointsApi
.ClonePagerDutyEndpointAsync("not-found-cloned", "token", "020f755c3c082000"));

Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message);
Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message);

ioe = Assert.ThrowsAsync<AggregateException>(async () => await _notificationEndpointsApi
.CloneHttpEndpointAsync("not-found-cloned", "020f755c3c082000"));

Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message);
Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message);

ioe = Assert.ThrowsAsync<AggregateException>(async () => await _notificationEndpointsApi
.CloneHttpEndpointBearerAsync("not-found-cloned", "token", "020f755c3c082000"));

Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message);
Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message);

ioe = Assert.ThrowsAsync<AggregateException>(async () => await _notificationEndpointsApi
.CloneHttpEndpointBasicAuthAsync("not-found-cloned", "username", "password", "020f755c3c082000"));

Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message);
Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message);
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions Client.Test/ItSourcesApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public async Task FindBucketsBySource()
[Test]
public void FindBucketsBySourceByUnknownSource()
{
var nfe = Assert.ThrowsAsync<AggregateException>(async () =>
var nfe = Assert.ThrowsAsync<HttpException>(async () =>
await _sourcesApi.FindBucketsBySourceIdAsync("020f755c3d082000"));

Assert.IsNotNull(nfe);
Assert.AreEqual("source not found", nfe.InnerException.Message);
Assert.AreEqual(typeof(HttpException), nfe.InnerException.GetType());
Assert.AreEqual("source not found", nfe.Message);
Assert.AreEqual(typeof(HttpException), nfe.GetType());
}

[Test]
Expand Down
18 changes: 9 additions & 9 deletions Client.Test/ItTasksApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ public async Task GetLogs()
[Test]
public void GetLogsNotExist()
{
var ioe = Assert.ThrowsAsync<AggregateException>(async () => await _tasksApi.GetLogsAsync("020f755c3c082000"));
var ioe = Assert.ThrowsAsync<HttpException>(async () => await _tasksApi.GetLogsAsync("020f755c3c082000"));

Assert.NotNull(ioe.InnerException, "ioe.InnerException != null");
Assert.AreEqual("failed to find task logs: task not found", ioe.InnerException.Message);
Assert.NotNull(ioe, "ioe.InnerException != null");
Assert.AreEqual("failed to find task logs: task not found", ioe.Message);
}

[Test]
Expand Down Expand Up @@ -372,10 +372,10 @@ public async Task GetRunLogsNotExist()
{
var task = await _tasksApi.CreateTaskEveryAsync(GenerateName("it task"), TaskFlux, "1s", _organization);

var ioe = Assert.ThrowsAsync<AggregateException>(async () => await _tasksApi.GetRunLogsAsync(task.Id, "020f755c3c082000"));
var ioe = Assert.ThrowsAsync<HttpException>(async () => await _tasksApi.GetRunLogsAsync(task.Id, "020f755c3c082000"));

Assert.NotNull(ioe.InnerException, "ioe.InnerException != null");
Assert.AreEqual("failed to find task logs: run not found", ioe.InnerException.Message);
Assert.NotNull(ioe, "ioe.InnerException != null");
Assert.AreEqual("failed to find task logs: run not found", ioe.Message);
}

[Test]
Expand Down Expand Up @@ -570,11 +570,11 @@ public async Task RunsLimit()
[Test]
public void RunsNotExist()
{
var ioe = Assert.ThrowsAsync<AggregateException>(async () =>
var ioe = Assert.ThrowsAsync<HttpException>(async () =>
await _tasksApi.GetRunsAsync("020f755c3c082000", _organization.Id));

Assert.NotNull(ioe.InnerException, "ioe.InnerException != null");
Assert.AreEqual("failed to find runs: task not found", ioe.InnerException.Message);
Assert.NotNull(ioe, "ioe.InnerException != null");
Assert.AreEqual("failed to find runs: task not found", ioe.Message);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Client.Test/ItUsersApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task FindUsers()

var users = await _usersApi.FindUsersAsync();

Assert.AreEqual(users.Count, size + 1);
Assert.AreEqual(size + 1, users.Count);
}

[Test]
Expand Down
3 changes: 1 addition & 2 deletions Client/AuthorizationsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ public async Task<List<Authorization>> FindAuthorizationsByUserNameAsync(string

private async Task<List<Authorization>> FindAuthorizationsByAsync(string userId, string userName)
{
return await _service.GetAuthorizationsAsync(null, userId, userName)
.ContinueWith(t => t.Result._Authorizations);
return (await _service.GetAuthorizationsAsync(null, userId, userName))._Authorizations;
}
}
}
19 changes: 8 additions & 11 deletions Client/BucketsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task<Bucket> CloneBucketAsync(string clonedName, string bucketId)
Arguments.CheckNonEmptyString(clonedName, nameof(clonedName));
Arguments.CheckNonEmptyString(bucketId, nameof(bucketId));

return await FindBucketByIdAsync(bucketId).ContinueWith(t => t.Result)
return await FindBucketByIdAsync(bucketId)
.ContinueWith(t => CloneBucketAsync(clonedName, t.Result)).Unwrap();
}

Expand Down Expand Up @@ -209,9 +209,8 @@ public async Task<Bucket> FindBucketByNameAsync(string bucketName)
{
Arguments.CheckNonEmptyString(bucketName, nameof(bucketName));

return await _service
.GetBucketsAsync(null, null, null, null, null, bucketName)
.ContinueWith(t => t.Result._Buckets.FirstOrDefault());
return (await _service.GetBucketsAsync(null, null, null, null, null, bucketName))
._Buckets.FirstOrDefault();
}

/// <summary>
Expand All @@ -233,9 +232,7 @@ public async Task<List<Bucket>> FindBucketsByOrganizationAsync(Organization orga
/// <returns>A list of buckets</returns>
public async Task<List<Bucket>> FindBucketsByOrgNameAsync(string orgName)
{
var buckets = FindBucketsAsync(orgName, new FindOptions());

return await buckets.ContinueWith(t => t.Result._Buckets);
return (await FindBucketsAsync(orgName, new FindOptions()))._Buckets;
}

/// <summary>
Expand Down Expand Up @@ -280,7 +277,7 @@ public async Task<List<ResourceMember>> GetMembersAsync(string bucketId)
{
Arguments.CheckNonEmptyString(bucketId, nameof(bucketId));

return await _service.GetBucketsIDMembersAsync(bucketId).ContinueWith(t => t.Result.Users);
return (await _service.GetBucketsIDMembersAsync(bucketId)).Users;
}

/// <summary>
Expand Down Expand Up @@ -362,7 +359,7 @@ public async Task<List<ResourceOwner>> GetOwnersAsync(string bucketId)
{
Arguments.CheckNonEmptyString(bucketId, nameof(bucketId));

return await _service.GetBucketsIDOwnersAsync(bucketId).ContinueWith(t => t.Result.Users);
return (await _service.GetBucketsIDOwnersAsync(bucketId)).Users;
}

/// <summary>
Expand Down Expand Up @@ -444,7 +441,7 @@ public async Task<List<Label>> GetLabelsAsync(string bucketId)
{
Arguments.CheckNonEmptyString(bucketId, nameof(bucketId));

return await _service.GetBucketsIDLabelsAsync(bucketId).ContinueWith(t => t.Result.Labels);
return (await _service.GetBucketsIDLabelsAsync(bucketId)).Labels;
}

/// <summary>
Expand Down Expand Up @@ -474,7 +471,7 @@ public async Task<Label> AddLabelAsync(string labelId, string bucketId)

var mapping = new LabelMapping(labelId);

return await _service.PostBucketsIDLabelsAsync(bucketId, mapping).ContinueWith(t => t.Result.Label);
return (await _service.PostBucketsIDLabelsAsync(bucketId, mapping)).Label;
}

/// <summary>
Expand Down
8 changes: 3 additions & 5 deletions Client/ChecksApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public async Task<List<Check>> FindChecksAsync(string orgId)
{
Arguments.CheckNonEmptyString(orgId, nameof(orgId));

return await FindChecksAsync(orgId, new FindOptions())
.ContinueWith(t => t.Result._Checks);
return (await FindChecksAsync(orgId, new FindOptions()))._Checks;
}

/// <summary>
Expand Down Expand Up @@ -227,7 +226,7 @@ public async Task<List<Label>> GetLabelsAsync(string checkId)
{
Arguments.CheckNonEmptyString(checkId, nameof(checkId));

return await _service.GetChecksIDLabelsAsync(checkId).ContinueWith(t => t.Result.Labels);
return (await _service.GetChecksIDLabelsAsync(checkId)).Labels;
}

/// <summary>
Expand Down Expand Up @@ -257,8 +256,7 @@ public async Task<Label> AddLabelAsync(string labelId, string checkId)

var mapping = new LabelMapping(labelId);

return await _service.PostChecksIDLabelsAsync(checkId, mapping)
.ContinueWith(t => t.Result.Label);
return (await _service.PostChecksIDLabelsAsync(checkId, mapping)).Label;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Client/InfluxDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ public async Task<OnboardingResponse> OnboardingAsync(OnboardingRequest onboardi
/// <returns>True if onboarding has already been completed otherwise false</returns>
public async Task<bool> IsOnboardingAllowedAsync()
{
var isOnboardingAllowed = _setupService.GetSetupAsync().ContinueWith(t => t.Result.Allowed == true);
var isOnboarding = await _setupService.GetSetupAsync();

return await isOnboardingAllowed;
return isOnboarding.Allowed == true;
}

internal static string AuthorizationHeader(string username, string password)
Expand Down
13 changes: 7 additions & 6 deletions Client/LabelsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<Label> CreateLabelAsync(LabelCreateRequest request)
{
Arguments.CheckNotNull(request, nameof(request));

return await _service.PostLabelsAsync(request).ContinueWith(t=> t.Result.Label);
return (await _service.PostLabelsAsync(request)).Label;
}

/// <summary>
Expand Down Expand Up @@ -69,7 +69,7 @@ public async Task<Label> UpdateLabelAsync(Label label)
/// <returns>Updated label</returns>
public async Task<Label> UpdateLabelAsync(string labelId, LabelUpdate labelUpdate)
{
return await _service.PatchLabelsIDAsync(labelId, labelUpdate).ContinueWith(t => t.Result.Label);
return (await _service.PatchLabelsIDAsync(labelId, labelUpdate)).Label;
}

/// <summary>
Expand Down Expand Up @@ -107,7 +107,8 @@ public async Task<Label> CloneLabelAsync(string clonedName, string labelId)
Arguments.CheckNonEmptyString(clonedName, nameof(clonedName));
Arguments.CheckNonEmptyString(labelId, nameof(labelId));

return await FindLabelByIdAsync(labelId).ContinueWith(t => CloneLabelAsync(clonedName, t.Result)).Unwrap();
return await FindLabelByIdAsync(labelId)
.ContinueWith(t => CloneLabelAsync(clonedName, t.Result)).Unwrap();
}

/// <summary>
Expand Down Expand Up @@ -136,7 +137,7 @@ public async Task<Label> FindLabelByIdAsync(string labelId)
{
Arguments.CheckNonEmptyString(labelId, nameof(labelId));

return await _service.GetLabelsIDAsync(labelId).ContinueWith(t => t.Result.Label);
return (await _service.GetLabelsIDAsync(labelId)).Label;
}

/// <summary>
Expand All @@ -145,7 +146,7 @@ public async Task<Label> FindLabelByIdAsync(string labelId)
/// <returns>List all labels.</returns>
public async Task<List<Label>> FindLabelsAsync()
{
return await _service.GetLabelsAsync().ContinueWith(t => t.Result.Labels);
return (await _service.GetLabelsAsync()).Labels;
}

/// <summary>
Expand All @@ -167,7 +168,7 @@ public async Task<List<Label>> FindLabelsByOrgAsync(Organization organization)
/// <returns>all labels</returns>
public async Task<List<Label>> FindLabelsByOrgIdAsync(string orgId)
{
return await _service.GetLabelsAsync(null, orgId).ContinueWith(t => t.Result.Labels);
return (await _service.GetLabelsAsync(null, orgId)).Labels;
}
}
}
Loading