Skip to content

Commit fc503aa

Browse files
committed
feat(csharp): update ChunkedPush and ReplaceAllObjectsWithTransformation methods to accept IEnumerable<object> for improved flexibility
1 parent 5772cf4 commit fc503aa

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Utils/IngestionClientExtensions.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,30 @@ public partial interface IIngestionClient
1818
/// Helper method to call ChunkedPushAsync and convert the response types.
1919
/// This simplifies SearchClient helpers that need to use IngestionClient.
2020
/// </summary>
21-
Task<List<WatchResponse>> ChunkedPushAsync<T>(
21+
Task<List<WatchResponse>> ChunkedPushAsync(
2222
string indexName,
23-
IEnumerable<T> objects,
23+
IEnumerable<object> objects,
2424
Models.Ingestion.Action action,
2525
bool waitForTasks = false,
2626
int batchSize = 1000,
2727
string referenceIndexName = null,
2828
RequestOptions options = null,
2929
CancellationToken cancellationToken = default
30-
)
31-
where T : class;
30+
);
3231

3332
/// <summary>
34-
/// Synchronous version of ChunkedPushWithSearchResponseAsync
33+
/// Synchronous version of ChunkedPushAsync
3534
/// </summary>
36-
List<WatchResponse> ChunkedPush<T>(
35+
List<WatchResponse> ChunkedPush(
3736
string indexName,
38-
IEnumerable<T> objects,
37+
IEnumerable<object> objects,
3938
Models.Ingestion.Action action,
4039
bool waitForTasks = false,
4140
int batchSize = 1000,
4241
string referenceIndexName = null,
4342
RequestOptions options = null,
4443
CancellationToken cancellationToken = default
45-
)
46-
where T : class;
44+
);
4745
}
4846

4947
public partial class IngestionClient : IIngestionClient
@@ -62,17 +60,16 @@ public partial class IngestionClient : IIngestionClient
6260
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
6361
/// <param name="cancellationToken">Cancellation token to cancel the request</param>
6462
/// <returns>List of WatchResponse objects from the push operations</returns>
65-
public async Task<List<WatchResponse>> ChunkedPushAsync<T>(
63+
public async Task<List<WatchResponse>> ChunkedPushAsync(
6664
string indexName,
67-
IEnumerable<T> objects,
65+
IEnumerable<object> objects,
6866
Algolia.Search.Models.Ingestion.Action action,
6967
bool waitForTasks = false,
7068
int batchSize = 1000,
7169
string referenceIndexName = null,
7270
RequestOptions options = null,
7371
CancellationToken cancellationToken = default
7472
)
75-
where T : class
7673
{
7774
var objectsList = objects.ToList();
7875
var responses = new List<WatchResponse>();
@@ -154,17 +151,16 @@ await RetryHelper.RetryUntil(
154151
/// <summary>
155152
/// Synchronous version of ChunkedPushAsync
156153
/// </summary>
157-
public List<WatchResponse> ChunkedPush<T>(
154+
public List<WatchResponse> ChunkedPush(
158155
string indexName,
159-
IEnumerable<T> objects,
156+
IEnumerable<object> objects,
160157
Algolia.Search.Models.Ingestion.Action action,
161158
bool waitForTasks = false,
162159
int batchSize = 1000,
163160
string referenceIndexName = null,
164161
RequestOptions options = null,
165162
CancellationToken cancellationToken = default
166-
)
167-
where T : class =>
163+
) =>
168164
AsyncHelper.RunSync(() =>
169165
ChunkedPushAsync(
170166
indexName,

clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,26 +504,24 @@ List<BatchResponse> PartialUpdateObjects<T>(
504504
/// <param name="scopes">The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].</param>
505505
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
506506
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
507-
Task<ReplaceAllObjectsWithTransformationResponse> ReplaceAllObjectsWithTransformationAsync<T>(
507+
Task<ReplaceAllObjectsWithTransformationResponse> ReplaceAllObjectsWithTransformationAsync(
508508
string indexName,
509-
IEnumerable<T> objects,
509+
IEnumerable<object> objects,
510510
int batchSize = 1000,
511511
List<ScopeType> scopes = null,
512512
RequestOptions options = null,
513513
CancellationToken cancellationToken = default
514-
)
515-
where T : class;
514+
);
516515

517-
/// <inheritdoc cref="ReplaceAllObjectsWithTransformationAsync{T}(string, IEnumerable{T}, int, List{ScopeType}, RequestOptions, CancellationToken)"/>
518-
ReplaceAllObjectsWithTransformationResponse ReplaceAllObjectsWithTransformation<T>(
516+
/// <inheritdoc cref="ReplaceAllObjectsWithTransformationAsync(string, IEnumerable{object}, int, List{ScopeType}, RequestOptions, CancellationToken)"/>
517+
ReplaceAllObjectsWithTransformationResponse ReplaceAllObjectsWithTransformation(
519518
string indexName,
520-
IEnumerable<T> objects,
519+
IEnumerable<object> objects,
521520
int batchSize = 1000,
522521
List<ScopeType> scopes = null,
523522
RequestOptions options = null,
524523
CancellationToken cancellationToken = default
525-
)
526-
where T : class;
524+
);
527525
}
528526

529527
public partial class SearchClient : ISearchClient
@@ -1371,15 +1369,14 @@ public async Task<
13711369
// ==================== ReplaceAllObjectsWithTransformation ====================
13721370

13731371
/// <inheritdoc/>
1374-
public async Task<ReplaceAllObjectsWithTransformationResponse> ReplaceAllObjectsWithTransformationAsync<T>(
1372+
public async Task<ReplaceAllObjectsWithTransformationResponse> ReplaceAllObjectsWithTransformationAsync(
13751373
string indexName,
1376-
IEnumerable<T> objects,
1374+
IEnumerable<object> objects,
13771375
int batchSize = 1000,
13781376
List<ScopeType> scopes = null,
13791377
RequestOptions options = null,
13801378
CancellationToken cancellationToken = default
13811379
)
1382-
where T : class
13831380
{
13841381
if (_ingestionTransporter == null)
13851382
{
@@ -1491,15 +1488,14 @@ await DeleteIndexAsync(tmpIndexName, cancellationToken: cancellationToken)
14911488
}
14921489

14931490
/// <inheritdoc/>
1494-
public ReplaceAllObjectsWithTransformationResponse ReplaceAllObjectsWithTransformation<T>(
1491+
public ReplaceAllObjectsWithTransformationResponse ReplaceAllObjectsWithTransformation(
14951492
string indexName,
1496-
IEnumerable<T> objects,
1493+
IEnumerable<object> objects,
14971494
int batchSize = 1000,
14981495
List<ScopeType> scopes = null,
14991496
RequestOptions options = null,
15001497
CancellationToken cancellationToken = default
1501-
)
1502-
where T : class =>
1498+
) =>
15031499
AsyncHelper.RunSync(() =>
15041500
ReplaceAllObjectsWithTransformationAsync(
15051501
indexName,

0 commit comments

Comments
 (0)