-
Notifications
You must be signed in to change notification settings - Fork 0
/
influxdb-client-csharp.patch
251 lines (222 loc) · 11.8 KB
/
influxdb-client-csharp.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
diff --git a/Client.Test/ItBucketsApiTest.cs b/Client.Test/ItBucketsApiTest.cs
index 0eef7d9..561fbdd 100644
--- a/Client.Test/ItBucketsApiTest.cs
+++ b/Client.Test/ItBucketsApiTest.cs
@@ -53,7 +53,7 @@ namespace InfluxDB.Client.Test
Assert.AreEqual(name, cloned.Name);
Assert.AreEqual(_organization.Id, cloned.OrgID);
- Assert.IsNull(cloned.Rp);
+ Assert.AreEqual("0", cloned.Rp);
Assert.AreEqual(1, cloned.RetentionRules.Count);
Assert.AreEqual(3600, cloned.RetentionRules[0].EverySeconds);
Assert.AreEqual(BucketRetentionRules.TypeEnum.Expire, cloned.RetentionRules[0].Type);
diff --git a/Client.Test/ItUsersApiTest.cs b/Client.Test/ItUsersApiTest.cs
index 5c7307b..5cc929c 100644
--- a/Client.Test/ItUsersApiTest.cs
+++ b/Client.Test/ItUsersApiTest.cs
@@ -1,4 +1,3 @@
-using System;
using System.Linq;
using System.Threading.Tasks;
using InfluxDB.Client.Core.Exceptions;
@@ -109,36 +108,32 @@ namespace InfluxDB.Client.Test
}
[Test]
- [Property("basic_auth", "true")]
- [Ignore("TODO not implemented set password https://github.com/influxdata/influxdb/pull/15981")]
public async Task UpdatePassword()
{
var user = await _usersApi.MeAsync();
Assert.IsNotNull(user);
- await _usersApi.UpdateUserPasswordAsync(user, "my-password", "my-password");
+ await _usersApi.UpdateUserPasswordAsync(user, "my-password");
}
[Test]
- [Property("basic_auth", "true")]
- [Ignore("TODO not implemented set password https://github.com/influxdata/influxdb/pull/15981")]
public async Task UpdatePasswordById()
{
var user = await _usersApi.MeAsync();
Assert.IsNotNull(user);
- await _usersApi.UpdateUserPasswordAsync(user.Id, "my-password", "my-password");
+ await _usersApi.UpdateUserPasswordAsync(user.Id, "my-password");
}
[Test]
public void UpdatePasswordNotFound()
{
- var ioe = Assert.ThrowsAsync<AggregateException>(async () =>
- await _usersApi.UpdateUserPasswordAsync("020f755c3c082000", "", "new-password"));
+ var ioe = Assert.ThrowsAsync<ForbiddenException>(async () =>
+ await _usersApi.UpdateUserPasswordAsync("020f755c3c082000", "new-password"));
Assert.IsNotNull(ioe);
- Assert.AreEqual("user not found", ioe.InnerException.Message);
- Assert.AreEqual(typeof(NotFoundException), ioe.InnerException.GetType());
+ Assert.AreEqual("your userID is incorrect", ioe.Message);
+ Assert.AreEqual(typeof(ForbiddenException), ioe.GetType());
}
[Test]
diff --git a/Client/InvokableScriptsApi.cs b/Client/InvokableScriptsApi.cs
index 79f4b06..a1921fd 100644
--- a/Client/InvokableScriptsApi.cs
+++ b/Client/InvokableScriptsApi.cs
@@ -174,7 +174,7 @@ namespace InfluxDB.Client
public Task<List<Script>> FindScriptsAsync(int? offset = null, int? limit = null,
CancellationToken cancellationToken = default)
{
- return _service.GetScriptsAsync(limit, offset, cancellationToken)
+ return _service.GetScriptsAsync(limit, offset, cancellationToken: cancellationToken)
.ContinueWith(t => t.Result._Scripts, cancellationToken);
}
diff --git a/Client/TasksApi.cs b/Client/TasksApi.cs
index 98c4276..0993046 100644
--- a/Client/TasksApi.cs
+++ b/Client/TasksApi.cs
@@ -531,8 +531,8 @@ namespace InfluxDB.Client
Arguments.CheckNotNull(task, nameof(task));
var status = (TaskStatusType)Enum.Parse(typeof(TaskStatusType), task.Status.ToString());
- var taskCreateRequest = new TaskCreateRequest(task.OrgID, task.Org, status,
- task.Flux, task.Description);
+ var taskCreateRequest = new TaskCreateRequest(orgID: task.OrgID, org: task.Org, status: status,
+ flux: task.Flux, description: task.Description);
return CreateTaskAsync(taskCreateRequest, cancellationToken);
}
@@ -733,8 +733,8 @@ namespace InfluxDB.Client
Arguments.CheckNotNull(task, nameof(task));
var status = (TaskStatusType)Enum.Parse(typeof(TaskStatusType), task.Status.ToString());
- var cloned = new TaskCreateRequest(task.OrgID, task.Org, status,
- task.Flux, task.Description);
+ var cloned = new TaskCreateRequest(orgID: task.OrgID, org: task.Org, status: status,
+ flux: task.Flux, description: task.Description);
var created = await CreateTaskAsync(cloned, cancellationToken).ConfigureAwait(false);
var labels = await GetLabelsAsync(task, cancellationToken).ConfigureAwait(false);
diff --git a/Client/UsersApi.cs b/Client/UsersApi.cs
index bb4899a..a5a920e 100644
--- a/Client/UsersApi.cs
+++ b/Client/UsersApi.cs
@@ -39,22 +39,20 @@ namespace InfluxDB.Client
/// Update password to an user.
/// </summary>
/// <param name="user">user to update password</param>
- /// <param name="oldPassword">old password</param>
/// <param name="newPassword">new password</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>user updated</returns>
- Task UpdateUserPasswordAsync(User user, string oldPassword, string newPassword,
+ Task UpdateUserPasswordAsync(User user, string newPassword,
CancellationToken cancellationToken = default);
/// <summary>
/// Update password to an user.
/// </summary>
/// <param name="userId">ID of user to update password</param>
- /// <param name="oldPassword">old password</param>
/// <param name="newPassword">new password</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>user updated</returns>
- Task UpdateUserPasswordAsync(string userId, string oldPassword, string newPassword,
+ Task UpdateUserPasswordAsync(string userId, string newPassword,
CancellationToken cancellationToken = default);
/// <summary>
@@ -152,7 +150,7 @@ namespace InfluxDB.Client
{
Arguments.CheckNonEmptyString(name, nameof(name));
- var user = new User(name: name);
+ var user = new User(name);
return CreateUserAsync(user, cancellationToken);
}
@@ -187,37 +185,33 @@ namespace InfluxDB.Client
/// Update password to an user.
/// </summary>
/// <param name="user">user to update password</param>
- /// <param name="oldPassword">old password</param>
/// <param name="newPassword">new password</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>user updated</returns>
- public Task UpdateUserPasswordAsync(User user, string oldPassword, string newPassword,
+ public Task UpdateUserPasswordAsync(User user, string newPassword,
CancellationToken cancellationToken = default)
{
Arguments.CheckNotNull(user, nameof(user));
- Arguments.CheckNotNull(oldPassword, nameof(oldPassword));
Arguments.CheckNotNull(newPassword, nameof(newPassword));
- return UpdateUserPasswordAsync(user.Id, user.Name, oldPassword, newPassword, cancellationToken);
+ return UpdateUserPasswordAsync(user.Id, newPassword, cancellationToken);
}
/// <summary>
/// Update password to an user.
/// </summary>
/// <param name="userId">ID of user to update password</param>
- /// <param name="oldPassword">old password</param>
/// <param name="newPassword">new password</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>user updated</returns>
- public Task UpdateUserPasswordAsync(string userId, string oldPassword, string newPassword,
+ public Task UpdateUserPasswordAsync(string userId, string newPassword,
CancellationToken cancellationToken = default)
{
Arguments.CheckNotNull(userId, nameof(userId));
- Arguments.CheckNotNull(oldPassword, nameof(oldPassword));
Arguments.CheckNotNull(newPassword, nameof(newPassword));
- return FindUserByIdAsync(userId, cancellationToken)
- .ContinueWith(t => UpdateUserPasswordAsync(t.Result, oldPassword, newPassword), cancellationToken);
+ return _service.PostUsersIDPasswordAsync(userId, new PasswordResetBody(newPassword), null,
+ cancellationToken);
}
/// <summary>
@@ -276,7 +270,7 @@ namespace InfluxDB.Client
Arguments.CheckNonEmptyString(clonedName, nameof(clonedName));
Arguments.CheckNotNull(user, nameof(user));
- var cloned = new User(name: clonedName);
+ var cloned = new User(clonedName);
return CreateUserAsync(cloned, cancellationToken);
}
@@ -349,24 +343,10 @@ namespace InfluxDB.Client
return response._Users;
}
- private Task UpdateUserPasswordAsync(string userId, string userName, string oldPassword,
- string newPassword, CancellationToken cancellationToken = default)
- {
- Arguments.CheckNotNull(userId, nameof(userId));
- Arguments.CheckNotNull(userName, nameof(userName));
- Arguments.CheckNotNull(oldPassword, nameof(oldPassword));
- Arguments.CheckNotNull(newPassword, nameof(newPassword));
-
- var header = InfluxDBClient.AuthorizationHeader(userName, oldPassword);
-
- return _service.PostUsersIDPasswordAsync(userId, new PasswordResetBody(newPassword), null, header,
- cancellationToken);
- }
-
private PostUser ToPostUser(User user)
{
Enum.TryParse(user.Status.ToString(), true, out PostUser.StatusEnum status);
- var postUser = new PostUser(user.OauthID, user.Name, status);
+ var postUser = new PostUser(name: user.Name, status: status);
return postUser;
}
}
diff --git a/Client/WriteApiAsync.cs b/Client/WriteApiAsync.cs
index b64249c..0483f75 100644
--- a/Client/WriteApiAsync.cs
+++ b/Client/WriteApiAsync.cs
@@ -415,9 +415,9 @@ namespace InfluxDB.Client
return Task.CompletedTask;
}
- return _service.PostWriteAsync(org, bucket, Encoding.UTF8.GetBytes(sb.ToString()), null,
- PostHeaderEncoding, PostHeaderContentType, null, PostHeaderAccept, null, precision,
- cancellationToken);
+ return _service.PostWriteAsync(org: org, bucket: bucket, body: Encoding.UTF8.GetBytes(sb.ToString()),
+ contentEncoding: PostHeaderEncoding, contentType: PostHeaderContentType, accept: PostHeaderAccept,
+ precision: precision, cancellationToken: cancellationToken);
}
private Task<RestResponse> WriteDataAsyncWithIRestResponse(IEnumerable<BatchWriteData> batch,
@@ -433,9 +433,10 @@ namespace InfluxDB.Client
var sb = ToLineProtocolBody(batch);
- return _service.PostWriteAsyncWithIRestResponse(org, bucket, Encoding.UTF8.GetBytes(sb.ToString()), null,
- PostHeaderEncoding, PostHeaderContentType, null, PostHeaderAccept, null, precision,
- cancellationToken);
+ return _service.PostWriteAsyncWithIRestResponse(org: org, bucket: bucket,
+ body: Encoding.UTF8.GetBytes(sb.ToString()), contentEncoding: PostHeaderEncoding,
+ contentType: PostHeaderContentType, accept: PostHeaderAccept, precision: precision,
+ cancellationToken: cancellationToken);
}
private static StringBuilder ToLineProtocolBody(IEnumerable<BatchWriteData> data)