Skip to content

Commit ba458b7

Browse files
authored
Merge pull request #396 from ArangoDB-Community/feature-3.8/DE-267-Deprecate-usage-of-deprecated-server-apis
Deprecate methods and provide replacement for PutCursorAsync
2 parents 34e2ccd + ad8c44f commit ba458b7

12 files changed

+85
-16
lines changed

arangodb-net-standard.Test/CollectionApi/CollectionApiClientTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public async Task PutCollectionPropertyAsync_ShouldThrow_WhenCollectionDoesNotEx
442442
{
443443
var body = new PutCollectionPropertyBody
444444
{
445-
JournalSize = 313136,
445+
//JournalSize = 313136,
446446
WaitForSync = false
447447
};
448448
var exception = await Assert.ThrowsAsync<ApiErrorException>(async () =>

arangodb-net-standard.Test/CursorApi/CursorApiClientTest.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,50 +280,54 @@ public async Task PostCursorAsync_ShouldReturnResponseModelWithInterface()
280280
}
281281

282282
[Fact]
283-
public async Task PutCursorAsync_ShouldSucceed()
283+
[Trait("ServerVersion", "3_8_PLUS")]
284+
public async Task PostAdvanceCursorAsync_ShouldSucceed()
284285
{
285286
var response = await _cursorApi.PostCursorAsync<long>("FOR i IN 0..1000 RETURN i");
286287
Assert.True(response.HasMore);
287288

288-
var nextResponse = await _cursorApi.PutCursorAsync<long>(response.Id);
289+
var nextResponse = await _cursorApi.PostAdvanceCursorAsync<long>(response.Id);
289290
Assert.False(nextResponse.HasMore);
290291
Assert.Single(nextResponse.Result);
291292
Assert.Equal(1000, nextResponse.Result.First());
292293
Assert.Equal(HttpStatusCode.OK, nextResponse.Code);
293294
}
294295

295296
[Fact]
296-
public async Task PutCursorAsync_ShouldThrow_WhenCursorIsExhausted()
297+
[Trait("ServerVersion", "3_8_PLUS")]
298+
public async Task PostAdvanceCursorAsync_ShouldThrow_WhenCursorIsExhausted()
297299
{
298300
var response = await _cursorApi.PostCursorAsync<long>("FOR i IN 0..1000 RETURN i");
299301
Assert.True(response.HasMore);
300302

301-
var nextResponse = await _cursorApi.PutCursorAsync<long>(response.Id);
303+
var nextResponse = await _cursorApi.PostAdvanceCursorAsync<long>(response.Id);
302304
Assert.False(nextResponse.HasMore);
303305

304306
await Assert.ThrowsAsync<ApiErrorException>(async () =>
305-
await _cursorApi.PutCursorAsync<long>(response.Id));
307+
await _cursorApi.PostAdvanceCursorAsync<long>(response.Id));
306308
}
307309

308310
[Fact]
309-
public async Task PutCursorAsync_ShouldThrow_WhenCursorDoesNotExist()
311+
[Trait("ServerVersion", "3_8_PLUS")]
312+
public async Task PostAdvanceCursorAsync_ShouldThrow_WhenCursorDoesNotExist()
310313
{
311314
var ex = await Assert.ThrowsAsync<ApiErrorException>(async () =>
312-
await _cursorApi.PutCursorAsync<long>("nada"));
315+
await _cursorApi.PostAdvanceCursorAsync<long>("nada"));
313316

314317
Assert.NotNull(ex.ApiError.ErrorMessage);
315318
Assert.Equal(1600, ex.ApiError.ErrorNum);
316319
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
317320
}
318321

319322
[Fact]
320-
public async Task PutCursorAsync_ShouldReturnResponseModelWithInterface()
323+
[Trait("ServerVersion", "3_8_PLUS")]
324+
public async Task PostAdvanceCursorAsync_ShouldReturnResponseModelWithInterface()
321325
{
322326
CursorResponse<int> postResponse =
323327
await _cursorApi.PostCursorAsync<int>("FOR i IN 0..1500 RETURN i");
324328

325329
ICursorResponse<int> putResult =
326-
await _cursorApi.PutCursorAsync<int>(postResponse.Id);
330+
await _cursorApi.PostAdvanceCursorAsync<int>(postResponse.Id);
327331

328332
Assert.NotNull(putResult);
329333
}

arangodb-net-standard.Test/Docs/UsageTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ await adb.Document.PostDocumentAsync(
106106
var response = await adb.Cursor.PostCursorAsync<MyClassDocument>(
107107
@"FOR doc IN MyCollection
108108
FILTER doc.ItemNumber == 123456
109-
RETURN doc");
109+
RETURN doc", null);
110110

111111
MyClassDocument item = response.Result.First();
112112

arangodb-net-standard/CollectionApi/Models/GetCollectionFiguresResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class GetCollectionFiguresResponse
1414

1515
public string Id { get; set; }
1616

17+
[System.Obsolete()]
1718
public int IndexBuckets { get; set; }
1819

1920
public string Error { get; set; }
@@ -24,12 +25,15 @@ public class GetCollectionFiguresResponse
2425

2526
public int Status { get; set; }
2627

28+
[System.Obsolete()]
2729
public int JournalSize { get; set; }
2830

31+
[System.Obsolete()]
2932
public bool IsVolatile { get; set; }
3033

3134
public string Name { get; set; }
3235

36+
[System.Obsolete()]
3337
public bool DoCompact { get; set; }
3438

3539
public bool IsSystem { get; set; }

arangodb-net-standard/CollectionApi/Models/GetCollectionPropertiesResponse.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ public class GetCollectionPropertiesResponse
1717
/// Whether or not the collection is compacted.
1818
/// This option is meaningful for the MMFiles storage engine only.
1919
/// </summary>
20+
[System.Obsolete()]
2021
public bool DoCompact { get; set; }
2122

2223
/// <summary>
2324
/// The maximal size of a journal or datafile in bytes.
2425
/// This option is meaningful for the MMFiles storage engine only.
2526
/// </summary>
27+
[System.Obsolete()]
2628
public int JournalSize { get; set; }
2729

2830
/// <summary>
@@ -35,6 +37,7 @@ public class GetCollectionPropertiesResponse
3537
/// If true then the collection data is kept in-memory only and not made persistent.
3638
/// This option is meaningful for the MMFiles storage engine only.
3739
/// </summary>
40+
[System.Obsolete()]
3841
public bool IsVolatile { get; set; }
3942

4043
/// <summary>

arangodb-net-standard/CollectionApi/Models/GetCollectionRevisionResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ public class GetCollectionRevisionResponse
1919

2020
public bool WaitForSync { get; set; }
2121

22+
[System.Obsolete()]
2223
public int JournalSize { get; set; }
2324

25+
[System.Obsolete()]
2426
public bool IsVolatile { get; set; }
2527

2628
public bool IsSystem { get; set; }
2729

30+
[System.Obsolete()]
2831
public int IndexBuckets { get; set; }
2932

3033
public CollectionKeyOptions KeyOptions { get; set; }
@@ -43,6 +46,7 @@ public class GetCollectionRevisionResponse
4346

4447
public string Name { get; set; }
4548

49+
[System.Obsolete()]
4650
public bool DoCompact { get; set; }
4751
}
4852
}

arangodb-net-standard/CollectionApi/Models/PostCollectionBody.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class PostCollectionBody
1919
/// Whether or not the collection will be compacted (default is true).
2020
/// This option is meaningful for the MMFiles storage engine only.
2121
/// </summary>
22+
[System.Obsolete()]
2223
public bool? DoCompact { get; set; }
2324

2425
/// <summary>
@@ -32,6 +33,8 @@ public class PostCollectionBody
3233
/// For example, 64 might be a sensible value for a collection with 100 000 000 documents.
3334
/// This option is meaningful for the MMFiles storage engine only.
3435
/// </summary>
36+
///
37+
[System.Obsolete()]
3538
public int? IndexBuckets { get; set; }
3639

3740
/// <summary>
@@ -53,6 +56,7 @@ public class PostCollectionBody
5356
/// and not for data that cannot be re-created otherwise. (The default is false)
5457
/// This option is meaningful for the MMFiles storage engine only.
5558
/// </summary>
59+
[System.Obsolete()]
5660
public bool? IsVolatile { get; set; }
5761

5862
/// <summary>
@@ -62,6 +66,7 @@ public class PostCollectionBody
6266
/// (The default is a configuration parameter)
6367
/// This option is meaningful for the MMFiles storage engine only.
6468
/// </summary>
69+
[System.Obsolete()]
6570
public long? JournalSize { get; set; }
6671

6772
/// <summary>

arangodb-net-standard/CollectionApi/Models/PostCollectionResponse.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class PostCollectionResponse
3434
/// The maximal size of a journal or datafile in bytes.
3535
/// This option is meaningful for the MMFiles storage engine only.
3636
/// </summary>
37+
///
38+
[System.Obsolete()]
3739
public long JournalSize { get; set; }
3840

3941
public PostCollectionResponseCollectionKeyOptions KeyOptions { get; set; }
@@ -54,6 +56,8 @@ public class PostCollectionResponse
5456
/// Whether or not the collection is compacted.
5557
/// This option is meaningful for the MMFiles storage engine only.
5658
/// </summary>
59+
///
60+
[System.Obsolete()]
5761
public bool DoCompact { get; set; }
5862

5963
/// <summary>
@@ -66,13 +70,17 @@ public class PostCollectionResponse
6670
/// The number of buckets into which indexes using a hash table are split.
6771
/// This option is meaningful for the MMFiles storage engine only.
6872
/// </summary>
73+
///
74+
[System.Obsolete()]
6975
public int IndexBuckets { get; set; }
7076

7177
/// <summary>
7278
/// Deprecated.
7379
/// If true then the collection data is kept in-memory only and not made persistent.
7480
/// This option is meaningful for the MMFiles storage engine only.
7581
/// </summary>
82+
///
83+
[System.Obsolete()]
7684
public bool IsVolatile { get; set; }
7785

7886
/// <summary>

arangodb-net-standard/CollectionApi/Models/PutCollectionPropertyBody.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class PutCollectionPropertyBody
44
{
55
public bool? WaitForSync { get; set; }
66

7+
[System.Obsolete()]
78
public long? JournalSize { get; set; }
89
}
910
}

arangodb-net-standard/CollectionApi/Models/PutCollectionPropertyResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class PutCollectionPropertyResponse
1010

1111
public bool WaitForSync { get; set; }
1212

13+
[System.Obsolete()]
1314
public long JournalSize { get; set; }
1415

1516
public int Status { get; set; }
@@ -18,8 +19,10 @@ public class PutCollectionPropertyResponse
1819

1920
public bool IsSystem { get; set; }
2021

22+
[System.Obsolete()]
2123
public bool IsVolatile { get; set; }
2224

25+
[System.Obsolete()]
2326
public bool DoCompact { get; set; }
2427

2528
public CollectionKeyOptions KeyOptions { get; set; }
@@ -41,6 +44,7 @@ public class PutCollectionPropertyResponse
4144

4245
public string StatusString { get; set; }
4346

47+
[System.Obsolete()]
4448
public int IndexBuckets { get; set; }
4549
}
4650
}

arangodb-net-standard/CursorApi/CursorApiClient.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Net;
34
using System.Threading;
45
using System.Threading.Tasks;
@@ -123,8 +124,8 @@ public virtual async Task<CursorResponse<T>> PostCursorAsync<T>(
123124
{
124125
var content = GetContent(postCursorBody, new ApiClientSerializationOptions(true, true));
125126
var headerCollection = GetHeaderCollection(headerProperties);
126-
using (var response = await _client.PostAsync(_cursorApiPath,
127-
content,
127+
using (var response = await _client.PostAsync(_cursorApiPath,
128+
content,
128129
headerCollection,
129130
token).ConfigureAwait(false))
130131
{
@@ -170,11 +171,12 @@ public virtual async Task<DeleteCursorResponse> DeleteCursorAsync(string cursorI
170171
/// <param name="cursorId">ID of the existing query cursor.</param>
171172
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param>
172173
/// <returns></returns>
174+
[Obsolete("Use PostAdvanceCursorAsync.")]
173175
public virtual async Task<PutCursorResponse<T>> PutCursorAsync<T>(string cursorId,
174176
CancellationToken token = default)
175177
{
176178
string uri = _cursorApiPath + "/" + WebUtility.UrlEncode(cursorId);
177-
using (var response = await _client.PutAsync(uri, new byte[0],null,token).ConfigureAwait(false))
179+
using (var response = await _client.PutAsync(uri, new byte[0], null, token).ConfigureAwait(false))
178180
{
179181
if (response.IsSuccessStatusCode)
180182
{
@@ -185,5 +187,28 @@ public virtual async Task<PutCursorResponse<T>> PutCursorAsync<T>(string cursorI
185187
throw await GetApiErrorException(response).ConfigureAwait(false);
186188
}
187189
}
190+
191+
/// <summary>
192+
/// Advances an existing query cursor and gets the next set of results.
193+
/// Replaces <see cref="PutCursorAsync{T}(string, CancellationToken)"/>
194+
/// </summary>
195+
/// <param name="cursorIdentifier">The name / identifier of the existing cursor.</param>
196+
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param>
197+
/// <returns></returns>
198+
public virtual async Task<PostCursorResponse<T>> PostAdvanceCursorAsync<T>(string cursorIdentifier, CancellationToken token = default)
199+
{
200+
using (var response = await _client.PostAsync(
201+
requestUri: _cursorApiPath + $"/{WebUtility.UrlEncode(cursorIdentifier)}",
202+
content: new byte[] { },
203+
token: token).ConfigureAwait(false))
204+
{
205+
if (response.IsSuccessStatusCode)
206+
{
207+
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
208+
return DeserializeJsonFromStream<PostCursorResponse<T>>(stream);
209+
}
210+
throw await GetApiErrorException(response).ConfigureAwait(false);
211+
}
212+
}
188213
}
189-
}
214+
}

arangodb-net-standard/CursorApi/ICursorApiClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ Task<CursorResponse<T>> PostCursorAsync<T>(
5353
CursorHeaderProperties headerProperties = null,
5454
CancellationToken token = default);
5555

56+
/// <summary>
57+
/// Advances an existing query cursor and gets the next set of results.
58+
/// Replaces <see cref="PutCursorAsync{T}(string, CancellationToken)"/>
59+
/// </summary>
60+
/// <param name="cursorIdentifier">The name / identifier of the existing cursor.</param>
61+
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param>
62+
/// <returns></returns>
63+
Task<PostCursorResponse<T>> PostAdvanceCursorAsync<T>(
64+
string cursorIdentifier,
65+
CancellationToken token = default);
66+
5667
/// <summary>
5768
/// Deletes an existing cursor and frees the resources associated with it.
5869
/// DELETE /_api/cursor/{cursor-identifier}

0 commit comments

Comments
 (0)