diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml
index caa61ea5..c5d4bd34 100644
--- a/.code-samples.meilisearch.yaml
+++ b/.code-samples.meilisearch.yaml
@@ -838,3 +838,7 @@ facet_search_3: |-
ExhaustiveFacetCount: true
};
await client.Index("books").FacetSearchAsync("genres", query);
+get_batch_1: |-
+ await client.GetBatchAsync(1);
+get_all_batches_1: |-
+ await client.GetBatchesAsync();
diff --git a/src/Meilisearch/BatchResult.cs b/src/Meilisearch/BatchResult.cs
new file mode 100644
index 00000000..a7dde98e
--- /dev/null
+++ b/src/Meilisearch/BatchResult.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+
+namespace Meilisearch
+{
+ ///
+ /// Batch Object
+ ///
+ public class BatchResult
+ {
+ ///
+ /// The unique sequential identifier of the batch.
+ ///
+ [JsonPropertyName("uid")]
+ public int Uid { get; }
+
+ ///
+ /// Detailed information on the batch progress.
+ ///
+ [JsonPropertyName("progress")]
+ public IReadOnlyCollection> Progress { get; }
+
+ ///
+ /// Detailed information on the batch.
+ ///
+ [JsonPropertyName("details")]
+ public IReadOnlyDictionary Details { get; }
+
+ ///
+ /// Detailed information on the stats.
+ ///
+ [JsonPropertyName("stats")]
+ public IReadOnlyDictionary Stats { get; }
+
+
+ ///
+ /// The total elapsed time the task spent in the processing state, in ISO 8601 format.
+ ///
+ [JsonPropertyName("duration")]
+
+ public string Duration { get; }
+ ///
+ /// The date and time when the task began processing, in RFC 3339 format.
+ ///
+ [JsonPropertyName("startedAt")]
+ public DateTime? StartedAt { get; }
+
+ ///
+ /// The date and time when the task finished processing, whether failed or succeeded, in RFC 3339 format.
+ ///
+ [JsonPropertyName("finishedAt")]
+ public DateTime? FinishedAt { get; }
+
+ ///
+ /// A string describing the logic behind the creation of the batch. Can contain useful information when diagnosing indexing performance issues.
+ ///
+ [JsonPropertyName("batchStrategy")]
+ public string BatchStrategy { get; }
+ }
+}
diff --git a/src/Meilisearch/TasksResults.cs b/src/Meilisearch/ChunkedResults.cs
similarity index 52%
rename from src/Meilisearch/TasksResults.cs
rename to src/Meilisearch/ChunkedResults.cs
index 680c803a..a5eb04ed 100644
--- a/src/Meilisearch/TasksResults.cs
+++ b/src/Meilisearch/ChunkedResults.cs
@@ -1,5 +1,3 @@
-using System.Collections.Generic;
-
namespace Meilisearch
{
///
@@ -7,9 +5,17 @@ namespace Meilisearch
/// When returning a list, Meilisearch stores the data in the "results" field, to allow better pagination.
///
/// Type of the Meilisearch server object. Ex: keys, indexes, ...
- public class TasksResults : Result
+ public class ChunkedResults : Result
{
- public TasksResults(T results, int? limit, int? from, int? next, int? total)
+ ///
+ /// Constructor for ChunkedResults.
+ ///
+ /// Results
+ /// Results limit
+ /// Uid of the first item returned
+ /// Value passed to from to view the next “page” of results. When the value of next is null, there are no more items to view
+ /// Total number of items matching the filter or query
+ public ChunkedResults(T results, int? limit, int? from, int? next, int? total)
: base(results, limit)
{
From = from;
@@ -28,7 +34,7 @@ public TasksResults(T results, int? limit, int? from, int? next, int? total)
public int? Next { get; }
///
- /// Gets total number of tasks.
+ /// Gets total number of results.
///
public int? Total { get; }
}
diff --git a/src/Meilisearch/Index.Tasks.cs b/src/Meilisearch/Index.Tasks.cs
index 0d7f1c8b..eb23d4f2 100644
--- a/src/Meilisearch/Index.Tasks.cs
+++ b/src/Meilisearch/Index.Tasks.cs
@@ -14,7 +14,7 @@ public partial class Index
/// Query parameters supports by the method.
/// The cancellation token for this call.
/// Returns a list of the operations status.
- public async Task>> GetTasksAsync(TasksQuery query = null, CancellationToken cancellationToken = default)
+ public async Task>> GetTasksAsync(TasksQuery query = null, CancellationToken cancellationToken = default)
{
if (query == null)
{
diff --git a/src/Meilisearch/MeilisearchClient.cs b/src/Meilisearch/MeilisearchClient.cs
index c4be414b..e77f2c88 100644
--- a/src/Meilisearch/MeilisearchClient.cs
+++ b/src/Meilisearch/MeilisearchClient.cs
@@ -469,6 +469,32 @@ public string GenerateTenantToken(string apiKeyUid, TenantTokenRules searchRules
return TenantToken.GenerateToken(apiKeyUid, searchRules, apiKey ?? ApiKey, expiresAt);
}
+ ///
+ /// Gets the Batches.
+ ///
+ /// Query parameters supports by the method.
+ /// The cancellation token for this call.
+ /// Returns a list of the batches.
+ public async Task>> GetBatchesAsync(BatchesQuery query = default, CancellationToken cancellationToken = default)
+ {
+ var uri = query.ToQueryString(uri: "batches");
+ return await _http.GetFromJsonAsync>>(uri, cancellationToken: cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Get a Batch.
+ ///
+ /// UId of the Batch.
+ /// The cancellation token for this call.
+ /// Returns the Batch.
+ public async Task GetBatchAsync(int batchUid, CancellationToken cancellationToken = default)
+ {
+ var uri = $"batches/{batchUid}";
+ return await _http.GetFromJsonAsync(uri, cancellationToken: cancellationToken)
+ .ConfigureAwait(false);
+ }
+
///
/// Create a local reference to a task, without doing an HTTP call.
///
diff --git a/src/Meilisearch/QueryParameters/BatchesQuery.cs b/src/Meilisearch/QueryParameters/BatchesQuery.cs
new file mode 100644
index 00000000..e067d752
--- /dev/null
+++ b/src/Meilisearch/QueryParameters/BatchesQuery.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+
+namespace Meilisearch.QueryParameters
+{
+ ///
+ /// A class that handles the creation of a query string for Batches.
+ ///
+ public class BatchesQuery
+ {
+ ///
+ /// Gets or sets the list of UIds to filter on.
+ ///
+ [JsonPropertyName("uids")]
+ public List UIds { get; set; }
+
+ ///
+ /// Gets or sets the list of Batch UIds to filter on.
+ ///
+ [JsonPropertyName("batchUids")]
+ public List BatchUIds { get; set; }
+
+ ///
+ /// Gets or sets the list of Index UIds to filter on.
+ ///
+ [JsonPropertyName("indexUids")]
+ public List IndexUIds { get; set; }
+
+ ///
+ /// Gets or sets the list of statuses to filter on.
+ ///
+ [JsonPropertyName("statuses")]
+ public List Statuses { get; set; }
+
+ ///
+ /// Gets or sets the list of types to filter on.
+ ///
+ [JsonPropertyName("types")]
+ public List Types { get; set; }
+
+ ///
+ /// Gets or sets the Number of tasks to return.
+ ///
+ [JsonPropertyName("limit")]
+ public int? Limit { get; set; } = 20;
+
+ ///
+ /// Gets or sets the uid of the first task returned.
+ ///
+ [JsonPropertyName("from")]
+ public int? From { get; set; }
+
+ ///
+ /// Gets or set the order of the returned tasks.
+ ///
+ [JsonPropertyName("reverse")]
+ public bool Reverse { get; set; } = false;
+
+ ///
+ /// Gets or sets the date before the task is enqueued to filter.
+ ///
+ [JsonPropertyName("beforeEnqueuedAt")]
+ public DateTime? BeforeEnqueuedAt { get; set; }
+
+ ///
+ /// Gets or sets the date before the task is started to filter.
+ ///
+ [JsonPropertyName("beforeStartedAt")]
+ public DateTime? BeforeStartedAt { get; set; }
+
+ ///
+ /// Gets or sets the date before the task is finished to filter.
+ ///
+ [JsonPropertyName("beforeFinishedAt")]
+ public DateTime? BeforeFinishedAt { get; set; }
+
+ ///
+ /// Gets or sets the date after the task is enqueued to filter.
+ ///
+ [JsonPropertyName("afterEnqueuedAt")]
+ public DateTime? AfterEnqueuedAt { get; set; }
+
+ ///
+ /// Gets or sets the date after the task is started to filter.
+ ///
+ [JsonPropertyName("afterStartedAt")]
+ public DateTime? AfterStartedAt { get; set; }
+
+ ///
+ /// Gets or sets the date after the task is finished to filter.
+ ///
+ [JsonPropertyName("afterFinishedAt")]
+ public DateTime? AfterFinishedAt { get; set; }
+ }
+}
diff --git a/src/Meilisearch/TaskEndpoint.cs b/src/Meilisearch/TaskEndpoint.cs
index e7f2fd32..73ea2e3b 100644
--- a/src/Meilisearch/TaskEndpoint.cs
+++ b/src/Meilisearch/TaskEndpoint.cs
@@ -24,10 +24,10 @@ public class TaskEndpoint
/// Query parameters supports by the method.
/// The cancellation token for this call.
/// Returns a list of the tasks.
- public async Task>> GetTasksAsync(TasksQuery query = default, CancellationToken cancellationToken = default)
+ public async Task>> GetTasksAsync(TasksQuery query = default, CancellationToken cancellationToken = default)
{
var uri = query.ToQueryString(uri: "tasks");
- return await _http.GetFromJsonAsync>>(uri, cancellationToken: cancellationToken)
+ return await _http.GetFromJsonAsync>>(uri, cancellationToken: cancellationToken)
.ConfigureAwait(false);
}
@@ -79,9 +79,9 @@ public async Task GetTaskAsync(int taskUid, CancellationToken canc
/// Uid of the index.
/// The cancellation token for this call.
/// Returns a list of tasks of an index.
- public async Task>> GetIndexTasksAsync(string indexUid, CancellationToken cancellationToken = default)
+ public async Task>> GetIndexTasksAsync(string indexUid, CancellationToken cancellationToken = default)
{
- return await _http.GetFromJsonAsync>>($"tasks?indexUid={indexUid}", cancellationToken: cancellationToken)
+ return await _http.GetFromJsonAsync>>($"tasks?indexUid={indexUid}", cancellationToken: cancellationToken)
.ConfigureAwait(false);
}