diff --git a/.nvmrc b/.nvmrc
index 7d41c735d71..b8ffd70759f 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-22.14.0
+22.15.0
diff --git a/clients/algoliasearch-client-csharp/.config/dotnet-tools.json b/clients/algoliasearch-client-csharp/.config/dotnet-tools.json
new file mode 100644
index 00000000000..96b59afa83f
--- /dev/null
+++ b/clients/algoliasearch-client-csharp/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "csharpier": {
+ "version": "1.0.1",
+ "commands": [
+ "csharpier"
+ ]
+ }
+ }
+}
diff --git a/clients/algoliasearch-client-csharp/.csharpierignore b/clients/algoliasearch-client-csharp/.csharpierignore
new file mode 100644
index 00000000000..7de5508b50d
--- /dev/null
+++ b/clients/algoliasearch-client-csharp/.csharpierignore
@@ -0,0 +1,2 @@
+obj
+bin
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Clients/AlgoliaConfig.cs b/clients/algoliasearch-client-csharp/algoliasearch/Clients/AlgoliaConfig.cs
index 15085fca5d9..bf733e3556f 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Clients/AlgoliaConfig.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Clients/AlgoliaConfig.cs
@@ -31,7 +31,7 @@ protected AlgoliaConfig(string appId, string apiKey, string clientName, string c
{ Defaults.AlgoliaApiKeyHeader.ToLowerInvariant(), ApiKey },
{ Defaults.UserAgentHeader.ToLowerInvariant(), "" },
{ Defaults.Connection.ToLowerInvariant(), Defaults.KeepAlive },
- { Defaults.AcceptHeader.ToLowerInvariant(), JsonConfig.JsonContentType }
+ { Defaults.AcceptHeader.ToLowerInvariant(), JsonConfig.JsonContentType },
};
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaException.cs b/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaException.cs
index 7967918cb69..2f53a07f66d 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaException.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaException.cs
@@ -11,9 +11,8 @@ public class AlgoliaException : Exception
/// Create a new Algolia exception.
///
/// The exception details.
- public AlgoliaException(string message) : base(message)
- {
- }
+ public AlgoliaException(string message)
+ : base(message) { }
///
/// Create a new Algolia exception, with an inner exception.
@@ -21,7 +20,5 @@ public AlgoliaException(string message) : base(message)
///
///
public AlgoliaException(string message, Exception inner)
- : base(message, inner)
- {
- }
+ : base(message, inner) { }
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaUnreachableHostException.cs b/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaUnreachableHostException.cs
index 9ff1ee3757f..f116f514ad0 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaUnreachableHostException.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Exceptions/AlgoliaUnreachableHostException.cs
@@ -11,7 +11,6 @@ public class AlgoliaUnreachableHostException : Exception
/// Create a new AlgoliaUnreachableHostException.
///
/// The exception details.
- public AlgoliaUnreachableHostException(string message) : base(message)
- {
- }
+ public AlgoliaUnreachableHostException(string message)
+ : base(message) { }
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaHttpRequester.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaHttpRequester.cs
index f6a58ac5cf8..bb12c007e9a 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaHttpRequester.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaHttpRequester.cs
@@ -21,8 +21,9 @@ internal class AlgoliaHttpRequester : IHttpRequester
private readonly HttpClient _httpClient = new(
new TimeoutHandler
{
- InnerHandler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }
- });
+ InnerHandler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip },
+ }
+ );
private readonly ILogger _logger;
@@ -41,8 +42,12 @@ public AlgoliaHttpRequester(ILoggerFactory loggerFactory)
/// Connect timeout
/// Optional cancellation token
///
- public async Task SendRequestAsync(Request request, TimeSpan requestTimeout,
- TimeSpan connectTimeout, CancellationToken ct = default)
+ public async Task SendRequestAsync(
+ Request request,
+ TimeSpan requestTimeout,
+ TimeSpan connectTimeout,
+ CancellationToken ct = default
+ )
{
if (request.Method == null)
{
@@ -58,7 +63,7 @@ public async Task SendRequestAsync(Request request, TimeSpa
{
Method = request.Method,
RequestUri = request.Uri,
- Content = request.Body != null ? new StreamContent(request.Body) : null
+ Content = request.Body != null ? new StreamContent(request.Body) : null,
};
if (request.Body != null && httpRequestMessage.Content != null)
@@ -73,7 +78,9 @@ public async Task SendRequestAsync(Request request, TimeSpa
try
{
using (httpRequestMessage)
- using (var response = await _httpClient.SendAsync(httpRequestMessage, ct).ConfigureAwait(false))
+ using (
+ var response = await _httpClient.SendAsync(httpRequestMessage, ct).ConfigureAwait(false)
+ )
{
using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
{
@@ -82,7 +89,7 @@ public async Task SendRequestAsync(Request request, TimeSpa
return new AlgoliaHttpResponse
{
Error = await StreamToStringAsync(stream),
- HttpStatusCode = (int)response.StatusCode
+ HttpStatusCode = (int)response.StatusCode,
};
}
@@ -93,7 +100,7 @@ public async Task SendRequestAsync(Request request, TimeSpa
return new AlgoliaHttpResponse
{
Body = outputStream,
- HttpStatusCode = (int)response.StatusCode
+ HttpStatusCode = (int)response.StatusCode,
};
}
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaUserAgent.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaUserAgent.cs
index da07d287bc8..31f5c3a8f4d 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaUserAgent.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/AlgoliaUserAgent.cs
@@ -47,7 +47,6 @@ public void AddSegment(string key, string value)
_segments.Add(new KeyValuePair(key, value));
}
-
///
/// Create a valid user-agent header
///
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/HttpRequestExtensions.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/HttpRequestExtensions.cs
index c5e1bae1d16..ad82a05eeb6 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/HttpRequestExtensions.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/HttpRequestExtensions.cs
@@ -22,7 +22,9 @@ internal static void SetTimeout(this HttpRequestMessage request, TimeSpan? timeo
{
if (request == null)
throw new ArgumentNullException(nameof(request));
- if (request.Properties.TryGetValue(TimeoutPropertyKey, out var value) && value is TimeSpan timeout)
+ if (
+ request.Properties.TryGetValue(TimeoutPropertyKey, out var value) && value is TimeSpan timeout
+ )
return timeout;
return null;
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/IHttpRequester.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/IHttpRequester.cs
index cb0f52dee23..5ae70264d26 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/IHttpRequester.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/IHttpRequester.cs
@@ -18,5 +18,10 @@ public interface IHttpRequester
/// Connect timeout
/// Optional cancellation token
///
- Task SendRequestAsync(Request request, TimeSpan requestTimeout, TimeSpan connectTimeout, CancellationToken ct = default);
+ Task SendRequestAsync(
+ Request request,
+ TimeSpan requestTimeout,
+ TimeSpan connectTimeout,
+ CancellationToken ct = default
+ );
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/InternalRequestOptions.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/InternalRequestOptions.cs
index 8d7fcc33c14..4bfda320784 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/InternalRequestOptions.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/InternalRequestOptions.cs
@@ -32,7 +32,8 @@ public InternalRequestOptions(RequestOptions options = null)
public void AddQueryParameter(string key, object value)
{
- if (value == null) return;
+ if (value == null)
+ return;
if (!QueryParameters.ContainsKey(key))
{
@@ -42,7 +43,8 @@ public void AddQueryParameter(string key, object value)
public void AddCustomQueryParameters(IDictionary values)
{
- if (values == null) return;
+ if (values == null)
+ return;
foreach (var t in values)
{
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/Request.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/Request.cs
index f6135136055..4250632b12b 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/Request.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/Request.cs
@@ -22,7 +22,7 @@ public class Request
public Uri Uri { get; set; }
///
- /// Headers
+ /// Headers
///
public IDictionary Headers { get; set; }
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/RequestOptionBuilder.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/RequestOptionBuilder.cs
index 6942e27f3ac..2ffea0b97d6 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/RequestOptionBuilder.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/RequestOptionBuilder.cs
@@ -18,7 +18,7 @@ public RequestOptionBuilder()
_options = new RequestOptions
{
Headers = new Dictionary(),
- QueryParameters = new Dictionary()
+ QueryParameters = new Dictionary(),
};
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Http/TimeoutHandler.cs b/clients/algoliasearch-client-csharp/algoliasearch/Http/TimeoutHandler.cs
index 26becb10932..6826b4b7044 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Http/TimeoutHandler.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Http/TimeoutHandler.cs
@@ -13,8 +13,10 @@ internal class TimeoutHandler : DelegatingHandler
{
private TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromSeconds(100);
- protected override async Task SendAsync(HttpRequestMessage request,
- CancellationToken cancellationToken)
+ protected override async Task SendAsync(
+ HttpRequestMessage request,
+ CancellationToken cancellationToken
+ )
{
using var cts = GetCancellationTokenSource(request, cancellationToken);
try
@@ -27,8 +29,10 @@ protected override async Task SendAsync(HttpRequestMessage
}
}
- private CancellationTokenSource GetCancellationTokenSource(HttpRequestMessage request,
- CancellationToken cancellationToken)
+ private CancellationTokenSource GetCancellationTokenSource(
+ HttpRequestMessage request,
+ CancellationToken cancellationToken
+ )
{
var timeout = request.GetTimeout() ?? DefaultTimeout;
if (timeout == Timeout.InfiniteTimeSpan)
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/CompressionType.cs b/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/CompressionType.cs
index e5d45615520..1d6c4affc4c 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/CompressionType.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/CompressionType.cs
@@ -13,5 +13,5 @@ public enum CompressionType
///
/// GZip Compression. Only supported by Search API.
///
- Gzip = 2
+ Gzip = 2,
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/SecuredApiKeyRestrictionHelper.cs b/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/SecuredApiKeyRestrictionHelper.cs
index 8d0ef66d99d..b10468e4d3d 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/SecuredApiKeyRestrictionHelper.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Models/Common/SecuredApiKeyRestrictionHelper.cs
@@ -1,9 +1,9 @@
+using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.Json.Serialization;
using Algolia.Search.Http;
using Algolia.Search.Utils;
-using System.Collections.Generic;
namespace Algolia.Search.Models.Search;
@@ -12,7 +12,6 @@ namespace Algolia.Search.Models.Search;
///
public partial class SecuredApiKeyRestrictions
{
-
///
/// Transforms the restriction into a query string
///
@@ -23,10 +22,14 @@ public string ToQueryString()
if (SearchParams != null)
{
// merge SearchParams into restrictions
- restrictions = restrictions.Concat(ToQueryMap(SearchParams)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+ restrictions = restrictions
+ .Concat(ToQueryMap(SearchParams))
+ .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
- return QueryStringHelper.ToQueryString(restrictions.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
+ return QueryStringHelper.ToQueryString(
+ restrictions.OrderBy(x => x.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
+ );
}
///
@@ -38,15 +41,18 @@ public string ToQueryString()
///
private static Dictionary ToQueryMap(T value, params string[] ignoreList)
{
- return typeof(T).GetTypeInfo()
+ return typeof(T)
+ .GetTypeInfo()
.DeclaredProperties.Where(p =>
- p.GetValue(value, null) != null && !ignoreList.Contains(p.Name) &&
- p.GetCustomAttribute() != null)
+ p.GetValue(value, null) != null
+ && !ignoreList.Contains(p.Name)
+ && p.GetCustomAttribute() != null
+ )
.Select(p => new
{
propsName = p.GetCustomAttribute().Name,
- value = QueryStringHelper.ParameterToString(p.GetValue(value, null))
- }).ToDictionary(p => p.propsName, p => p.value);
+ value = QueryStringHelper.ParameterToString(p.GetValue(value, null)),
+ })
+ .ToDictionary(p => p.propsName, p => p.value);
}
-
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/DefaultSerializer.cs b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/DefaultSerializer.cs
index 55aa08f018d..1aea8072196 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/DefaultSerializer.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/DefaultSerializer.cs
@@ -10,7 +10,8 @@ namespace Algolia.Search.Serializer;
internal class DefaultJsonSerializer(ILoggerFactory logger) : ISerializer
{
- private readonly ILogger _logger = logger.CreateLogger();
+ private readonly ILogger _logger =
+ logger.CreateLogger();
///
/// Serialize the object into a JSON string.
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/EnumConverter.cs b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/EnumConverter.cs
index a416972ece2..8c41dfea480 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/EnumConverter.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/EnumConverter.cs
@@ -37,7 +37,8 @@ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializer
///
/// Custom JsonConverter to convert enum to string, using the JsonPropertyNameAttribute if present
///
-public class JsonStringEnumConverter : JsonConverter where TEnum : struct, Enum
+public class JsonStringEnumConverter : JsonConverter
+ where TEnum : struct, Enum
{
private readonly Dictionary _enumToString = new();
private readonly Dictionary _stringToEnum = new();
@@ -52,7 +53,8 @@ public JsonStringEnumConverter()
foreach (var value in Enum.GetValues(type))
{
var enumMember = type.GetMember(value.ToString())[0];
- var attr = enumMember.GetCustomAttributes(typeof(JsonPropertyNameAttribute), false)
+ var attr = enumMember
+ .GetCustomAttributes(typeof(JsonPropertyNameAttribute), false)
.Cast()
.FirstOrDefault();
@@ -79,7 +81,11 @@ public JsonStringEnumConverter()
///
///
///
- public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override TEnum Read(
+ ref Utf8JsonReader reader,
+ Type typeToConvert,
+ JsonSerializerOptions options
+ )
{
var type = reader.TokenType;
switch (type)
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/JsonConfig.cs b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/JsonConfig.cs
index 2b09ab55c07..9bf8e49fef0 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Serializer/JsonConfig.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Serializer/JsonConfig.cs
@@ -17,9 +17,6 @@ internal static class JsonConfig
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip,
- Converters =
- {
- new SearchResultConverterFactory()
- }
+ Converters = { new SearchResultConverterFactory() },
};
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Transport/CallType.cs b/clients/algoliasearch-client-csharp/algoliasearch/Transport/CallType.cs
index 3d08f2bc0b4..bca52df1df9 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Transport/CallType.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Transport/CallType.cs
@@ -17,5 +17,5 @@ public enum CallType
///
/// Write Call
///
- Write = 2
+ Write = 2,
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpScheme.cs b/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpScheme.cs
index b4caad26ee9..2a116de6248 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpScheme.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpScheme.cs
@@ -9,8 +9,9 @@ public enum HttpScheme
/// Http
///
Http,
+
///
/// Https
///
- Https
+ Https,
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpTransport.cs b/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpTransport.cs
index 63c0957cf4d..2d64a1a511e 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpTransport.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Transport/HttpTransport.cs
@@ -28,9 +28,7 @@ internal class HttpTransport
private string _errorMessage;
private readonly ILogger _logger;
- private class VoidResult
- {
- }
+ private class VoidResult { }
///
/// Instantiate the transport class with the given configuration and requester
@@ -38,7 +36,11 @@ private class VoidResult
/// Algolia Config
/// An implementation of http requester
/// Logger factory
- public HttpTransport(AlgoliaConfig config, IHttpRequester httpClient, ILoggerFactory loggerFactory)
+ public HttpTransport(
+ AlgoliaConfig config,
+ IHttpRequester httpClient,
+ ILoggerFactory loggerFactory
+ )
{
_algoliaConfig = config ?? throw new ArgumentNullException(nameof(config));
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
@@ -55,9 +57,12 @@ public HttpTransport(AlgoliaConfig config, IHttpRequester httpClient, ILoggerFac
/// The endpoint URI
/// Add extra http header or query parameters to Algolia
/// Optional cancellation token
- public async Task ExecuteRequestAsync(HttpMethod method, string uri,
+ public async Task ExecuteRequestAsync(
+ HttpMethod method,
+ string uri,
InternalRequestOptions requestOptions = null,
- CancellationToken ct = default)
+ CancellationToken ct = default
+ )
where TResult : class =>
await ExecuteRequestAsync(method, uri, requestOptions, ct)
.ConfigureAwait(false);
@@ -69,11 +74,12 @@ await ExecuteRequestAsync(method, uri, requestOptions, ct)
/// The endpoint URI
/// Add extra http header or query parameters to Algolia
/// Optional cancellation token
- public async Task ExecuteRequestAsync(HttpMethod method, string uri,
+ public async Task ExecuteRequestAsync(
+ HttpMethod method,
+ string uri,
InternalRequestOptions requestOptions = null,
- CancellationToken ct = default) =>
- await ExecuteRequestAsync(method, uri, requestOptions, ct)
- .ConfigureAwait(false);
+ CancellationToken ct = default
+ ) => await ExecuteRequestAsync(method, uri, requestOptions, ct).ConfigureAwait(false);
///
/// Call api with retry strategy
@@ -84,9 +90,12 @@ await ExecuteRequestAsync(method, uri, requestOptions, ct)
/// The endpoint URI
/// Add extra http header or query parameters to Algolia
/// Optional cancellation token
- private async Task ExecuteRequestAsync(HttpMethod method, string uri,
+ private async Task ExecuteRequestAsync(
+ HttpMethod method,
+ string uri,
InternalRequestOptions requestOptions = null,
- CancellationToken ct = default)
+ CancellationToken ct = default
+ )
where TResult : class
where TData : class
{
@@ -104,22 +113,28 @@ private async Task ExecuteRequestAsync(HttpMethod metho
{
Method = method,
Headers = GenerateHeaders(requestOptions?.HeaderParameters),
- Compression = _algoliaConfig.Compression
+ Compression = _algoliaConfig.Compression,
};
var callType =
- (requestOptions?.UseReadTransporter != null && requestOptions.UseReadTransporter.Value) ||
- method == HttpMethod.Get
+ (requestOptions?.UseReadTransporter != null && requestOptions.UseReadTransporter.Value)
+ || method == HttpMethod.Get
? CallType.Read
: CallType.Write;
foreach (var host in _retryStrategy.GetTryableHost(callType))
{
request.Body = CreateRequestContent(requestOptions?.Data, request.CanCompress, _logger);
- request.Uri = BuildUri(host, uri, requestOptions?.CustomPathParameters, requestOptions?.PathParameters,
- requestOptions?.QueryParameters);
- var requestTimeout =
- TimeSpan.FromTicks((GetTimeOut(callType, requestOptions)).Ticks * (host.RetryCount + 1));
+ request.Uri = BuildUri(
+ host,
+ uri,
+ requestOptions?.CustomPathParameters,
+ requestOptions?.PathParameters,
+ requestOptions?.QueryParameters
+ );
+ var requestTimeout = TimeSpan.FromTicks(
+ (GetTimeOut(callType, requestOptions)).Ticks * (host.RetryCount + 1)
+ );
if (request.Body == null && (method == HttpMethod.Post || method == HttpMethod.Put))
{
@@ -137,7 +152,14 @@ private async Task ExecuteRequestAsync(HttpMethod metho
}
var response = await _httpClient
- .SendRequestAsync(request, requestTimeout, requestOptions?.ConnectTimeout ?? _algoliaConfig.ConnectTimeout ?? Defaults.ConnectTimeout, ct)
+ .SendRequestAsync(
+ request,
+ requestTimeout,
+ requestOptions?.ConnectTimeout
+ ?? _algoliaConfig.ConnectTimeout
+ ?? Defaults.ConnectTimeout,
+ ct
+ )
.ConfigureAwait(false);
_errorMessage = response.Error;
@@ -154,12 +176,13 @@ private async Task ExecuteRequestAsync(HttpMethod metho
{
var reader = new StreamReader(response.Body);
var json = await reader.ReadToEndAsync().ConfigureAwait(false);
- _logger.LogTrace(
- "Response HTTP {HttpCode}: {Json}", response.HttpStatusCode, json);
+ _logger.LogTrace("Response HTTP {HttpCode}: {Json}", response.HttpStatusCode, json);
response.Body.Seek(0, SeekOrigin.Begin);
}
- var deserialized = await _serializer.Deserialize(response.Body).ConfigureAwait(false);
+ var deserialized = await _serializer
+ .Deserialize(response.Body)
+ .ConfigureAwait(false);
if (_logger.IsEnabled(LogLevel.Trace))
{
@@ -171,8 +194,10 @@ private async Task ExecuteRequestAsync(HttpMethod metho
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug(
- "Retrying ... Retryable error for response HTTP {HttpCode} : {Error}", response.HttpStatusCode,
- response.Error);
+ "Retrying ... Retryable error for response HTTP {HttpCode} : {Error}",
+ response.HttpStatusCode,
+ response.Error
+ );
}
continue;
@@ -180,8 +205,10 @@ private async Task ExecuteRequestAsync(HttpMethod metho
if (_logger.IsEnabled(LogLevel.Error))
{
_logger.LogError(
- "Retry strategy with failure outcome. Response HTTP {HttpCode} : {Error}", response.HttpStatusCode,
- response.Error);
+ "Retry strategy with failure outcome. Response HTTP {HttpCode} : {Error}",
+ response.HttpStatusCode,
+ response.Error
+ );
}
throw new AlgoliaApiException(response.Error, response.HttpStatusCode);
@@ -195,7 +222,9 @@ private async Task ExecuteRequestAsync(HttpMethod metho
_logger.LogError("Retry strategy failed: {ErrorMessage}", _errorMessage);
}
- throw new AlgoliaUnreachableHostException("RetryStrategy failed to connect to Algolia. Reason: " + _errorMessage);
+ throw new AlgoliaUnreachableHostException(
+ "RetryStrategy failed to connect to Algolia. Reason: " + _errorMessage
+ );
}
///
@@ -223,7 +252,9 @@ private MemoryStream CreateRequestContent(T data, bool compress, ILogger logg
///
///
///
- private IDictionary GenerateHeaders(IDictionary optionalHeaders = null)
+ private IDictionary GenerateHeaders(
+ IDictionary optionalHeaders = null
+ )
{
return optionalHeaders != null && optionalHeaders.Any()
? optionalHeaders.MergeWith(_algoliaConfig.BuildHeaders())
@@ -239,10 +270,13 @@ private IDictionary GenerateHeaders(IDictionary
///
///
///
- private static Uri BuildUri(StatefulHost host, string baseUri,
+ private static Uri BuildUri(
+ StatefulHost host,
+ string baseUri,
IDictionary customPathParameters = null,
IDictionary pathParameters = null,
- IDictionary optionalQueryParameters = null)
+ IDictionary optionalQueryParameters = null
+ )
{
var path = $"{baseUri}";
if (pathParameters != null)
@@ -261,7 +295,12 @@ private static Uri BuildUri(StatefulHost host, string baseUri,
}
}
- var builder = new UriBuilder { Scheme = host.Scheme.ToString(), Host = host.Url, Path = path };
+ var builder = new UriBuilder
+ {
+ Scheme = host.Scheme.ToString(),
+ Host = host.Url,
+ Path = path,
+ };
if (optionalQueryParameters != null && optionalQueryParameters.Any())
{
@@ -286,9 +325,13 @@ private TimeSpan GetTimeOut(CallType callType, InternalRequestOptions requestOpt
{
return callType switch
{
- CallType.Read => requestOptions?.ReadTimeout ?? _algoliaConfig.ReadTimeout ?? Defaults.ReadTimeout,
- CallType.Write => requestOptions?.WriteTimeout ?? _algoliaConfig.WriteTimeout ?? Defaults.WriteTimeout,
- _ => Defaults.WriteTimeout
+ CallType.Read => requestOptions?.ReadTimeout
+ ?? _algoliaConfig.ReadTimeout
+ ?? Defaults.ReadTimeout,
+ CallType.Write => requestOptions?.WriteTimeout
+ ?? _algoliaConfig.WriteTimeout
+ ?? Defaults.WriteTimeout,
+ _ => Defaults.WriteTimeout,
};
}
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Transport/RetryStrategy.cs b/clients/algoliasearch-client-csharp/algoliasearch/Transport/RetryStrategy.cs
index 1a7bb083bde..497835e8e74 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Transport/RetryStrategy.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Transport/RetryStrategy.cs
@@ -112,8 +112,9 @@ private static bool IsSuccess(AlgoliaHttpResponse response)
///
private static bool IsRetryable(AlgoliaHttpResponse response)
{
- var isRetryableHttpCode = (int)Math.Floor((decimal)response.HttpStatusCode / 100) != 2 &&
- (int)Math.Floor((decimal)response.HttpStatusCode / 100) != 4;
+ var isRetryableHttpCode =
+ (int)Math.Floor((decimal)response.HttpStatusCode / 100) != 2
+ && (int)Math.Floor((decimal)response.HttpStatusCode / 100) != 4;
return isRetryableHttpCode || response.IsNetworkError;
}
@@ -162,5 +163,5 @@ public enum RetryOutcomeType
///
/// Call failed error
///
- Failure
+ Failure,
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Utils/AsyncHelper.cs b/clients/algoliasearch-client-csharp/algoliasearch/Utils/AsyncHelper.cs
index ee19d6d73f2..1bb5fb02c08 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Utils/AsyncHelper.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Utils/AsyncHelper.cs
@@ -9,22 +9,16 @@ namespace Algolia.Search.Utils;
///
internal static class AsyncHelper
{
- private static readonly TaskFactory TaskFactory = new(CancellationToken.None,
- TaskCreationOptions.None,
- TaskContinuationOptions.None,
- TaskScheduler.Default);
+ private static readonly TaskFactory TaskFactory = new(
+ CancellationToken.None,
+ TaskCreationOptions.None,
+ TaskContinuationOptions.None,
+ TaskScheduler.Default
+ );
- internal static TResult RunSync(Func> func)
- => TaskFactory
- .StartNew(func)
- .Unwrap()
- .GetAwaiter()
- .GetResult();
+ internal static TResult RunSync(Func> func) =>
+ TaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult();
- internal static void RunSync(Func func)
- => TaskFactory
- .StartNew(func)
- .Unwrap()
- .GetAwaiter()
- .GetResult();
+ internal static void RunSync(Func func) =>
+ TaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult();
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Utils/DictionaryHelper.cs b/clients/algoliasearch-client-csharp/algoliasearch/Utils/DictionaryHelper.cs
index 6dc8b2003e1..5f828cdbeda 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Utils/DictionaryHelper.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Utils/DictionaryHelper.cs
@@ -16,8 +16,10 @@ public static class DictionaryHelper
///
///
///
- public static IDictionary MergeWith(this IDictionary a,
- Dictionary b)
+ public static IDictionary MergeWith(
+ this IDictionary a,
+ Dictionary b
+ )
{
if (a == null && b != null)
{
@@ -29,7 +31,8 @@ public static IDictionary MergeWith(this IDictionary
return a;
}
- var mergeWith = a?.Concat(b.Where(kvp => !a.ContainsKey(kvp.Key) && kvp.Value != null))
+ var mergeWith = a
+ ?.Concat(b.Where(kvp => !a.ContainsKey(kvp.Key) && kvp.Value != null))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
return mergeWith;
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Utils/ModelConverters.cs b/clients/algoliasearch-client-csharp/algoliasearch/Utils/ModelConverters.cs
index e839c64cf24..57fb991caa8 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Utils/ModelConverters.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Utils/ModelConverters.cs
@@ -23,7 +23,7 @@ public static ApiKey ToApiKey(this GetApiKeyResponse apiKey)
Validity = apiKey.Validity,
QueryParameters = apiKey.QueryParameters,
MaxHitsPerQuery = apiKey.MaxHitsPerQuery,
- MaxQueriesPerIPPerHour = apiKey.MaxQueriesPerIPPerHour
+ MaxQueriesPerIPPerHour = apiKey.MaxQueriesPerIPPerHour,
};
}
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Utils/QueryStringHelper.cs b/clients/algoliasearch-client-csharp/algoliasearch/Utils/QueryStringHelper.cs
index db207abce9f..a890dda9b58 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Utils/QueryStringHelper.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Utils/QueryStringHelper.cs
@@ -17,9 +17,10 @@ public static string ToQueryString(this IDictionary dic)
throw new ArgumentNullException(nameof(dic));
}
- return string.Join("&",
- dic.Select(kvp =>
- string.Format($"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}")));
+ return string.Join(
+ "&",
+ dic.Select(kvp => string.Format($"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}"))
+ );
}
///
@@ -63,7 +64,10 @@ private static bool HasEnumMemberAttrValue(object enumVal)
throw new ArgumentNullException(nameof(enumVal));
var enumType = enumVal.GetType();
var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
- var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType()
+ var attr = memInfo
+ .FirstOrDefault()
+ ?.GetCustomAttributes(false)
+ .OfType()
.FirstOrDefault();
return attr != null;
}
@@ -79,7 +83,10 @@ private static string GetEnumMemberAttrValue(object enumVal)
throw new ArgumentNullException(nameof(enumVal));
var enumType = enumVal.GetType();
var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
- var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType()
+ var attr = memInfo
+ .FirstOrDefault()
+ ?.GetCustomAttributes(false)
+ .OfType()
.FirstOrDefault();
return attr?.Name;
}
diff --git a/clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs b/clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs
index 03c2b6813bf..c110137594d 100644
--- a/clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs
+++ b/clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs
@@ -24,9 +24,24 @@ public partial interface ISearchClient
/// The function to decide how long to wait between retries. Math.Min(retryCount * 200, 5000) by default. (optional)
/// The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
/// Cancellation token (optional)
- Task WaitForTaskAsync(string indexName, long taskId, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ Task WaitForTaskAsync(
+ string indexName,
+ long taskId,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
+
///
- GetTaskResponse WaitForTask(string indexName, long taskId, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ GetTaskResponse WaitForTask(
+ string indexName,
+ long taskId,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
///
/// Wait for an application-level task to complete with `taskID`.
@@ -36,9 +51,22 @@ public partial interface ISearchClient
/// The function to decide how long to wait between retries. Math.Min(retryCount * 200, 5000) by default. (optional)
/// The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
/// Cancellation token (optional)
- Task WaitForAppTaskAsync(long taskId, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ Task WaitForAppTaskAsync(
+ long taskId,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
+
///
- GetTaskResponse WaitForAppTask(long taskId, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ GetTaskResponse WaitForAppTask(
+ long taskId,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
///
/// Helper method that waits for an API key task to be processed.
@@ -50,9 +78,26 @@ public partial interface ISearchClient
/// The function to decide how long to wait between retries. Math.Min(retryCount * 200, 5000) by default. (optional)
/// The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
/// Cancellation token (optional)
- Task WaitForApiKeyAsync(string key, ApiKeyOperation operation, ApiKey apiKey = default, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ Task WaitForApiKeyAsync(
+ string key,
+ ApiKeyOperation operation,
+ ApiKey apiKey = default,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
+
///
- GetApiKeyResponse WaitForApiKey(string key, ApiKeyOperation operation, ApiKey apiKey = default, int maxRetries = SearchClient.DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default);
+ GetApiKeyResponse WaitForApiKey(
+ string key,
+ ApiKeyOperation operation,
+ ApiKey apiKey = default,
+ int maxRetries = SearchClient.DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ );
///
/// Iterate on the `browse` method of the client to allow aggregating objects of an index.
@@ -61,9 +106,18 @@ public partial interface ISearchClient
/// The `browse` parameters.
/// The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
/// The model of the record
- Task> BrowseObjectsAsync(string indexName, BrowseParamsObject browseParams, RequestOptions requestOptions = null);
+ Task> BrowseObjectsAsync(
+ string indexName,
+ BrowseParamsObject browseParams,
+ RequestOptions requestOptions = null
+ );
+
///
- IEnumerable BrowseObjects(string indexName, BrowseParamsObject browseParams, RequestOptions requestOptions = null);
+ IEnumerable BrowseObjects(
+ string indexName,
+ BrowseParamsObject browseParams,
+ RequestOptions requestOptions = null
+ );
///
/// Iterate on the `SearchRules` method of the client to allow aggregating rules of an index.
@@ -71,9 +125,18 @@ public partial interface ISearchClient
/// The index in which to perform the request.
/// The `SearchRules` parameters
/// The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
- Task> BrowseRulesAsync(string indexName, SearchRulesParams searchRulesParams, RequestOptions requestOptions = null);
+ Task> BrowseRulesAsync(
+ string indexName,
+ SearchRulesParams searchRulesParams,
+ RequestOptions requestOptions = null
+ );
+
///
- IEnumerable BrowseRules(string indexName, SearchRulesParams searchRulesParams, RequestOptions requestOptions = null);
+ IEnumerable BrowseRules(
+ string indexName,
+ SearchRulesParams searchRulesParams,
+ RequestOptions requestOptions = null
+ );
///
/// Iterate on the `SearchSynonyms` method of the client to allow aggregating rules of an index.
@@ -81,9 +144,18 @@ public partial interface ISearchClient
/// The index in which to perform the request.
/// The `SearchSynonyms` parameters.
/// The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
- Task> BrowseSynonymsAsync(string indexName, SearchSynonymsParams synonymsParams, RequestOptions requestOptions = null);
+ Task> BrowseSynonymsAsync(
+ string indexName,
+ SearchSynonymsParams synonymsParams,
+ RequestOptions requestOptions = null
+ );
+
///
- IEnumerable BrowseSynonyms(string indexName, SearchSynonymsParams synonymsParams, RequestOptions requestOptions = null);
+ IEnumerable BrowseSynonyms(
+ string indexName,
+ SearchSynonymsParams synonymsParams,
+ RequestOptions requestOptions = null
+ );
///
/// Generate a virtual API Key without any call to the server.
@@ -92,6 +164,7 @@ public partial interface ISearchClient
/// Restriction to add the key
///
string GenerateSecuredApiKey(string parentApiKey, SecuredApiKeyRestrictions restriction);
+
///
/// Get the remaining validity of a key generated by `GenerateSecuredApiKey`.
///
@@ -112,9 +185,20 @@ public partial interface ISearchClient
/// Thrown when the API call was rejected by Algolia
/// Thrown when the client failed to call the endpoint
/// Task of List{SearchResponse{T}}
- Task>> SearchForHitsAsync(IEnumerable requests, SearchStrategy? searchStrategy = null, RequestOptions options = null, CancellationToken cancellationToken = default);
+ Task>> SearchForHitsAsync(
+ IEnumerable requests,
+ SearchStrategy? searchStrategy = null,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
+
///
- List> SearchForHits(IEnumerable requests, SearchStrategy? searchStrategy = null, RequestOptions options = null, CancellationToken cancellationToken = default);
+ List> SearchForHits(
+ IEnumerable requests,
+ SearchStrategy? searchStrategy = null,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
///
/// Executes a synchronous search for the provided search requests, with certainty that we will only request Algolia facets. Results will be received in the same order as the queries.
@@ -127,9 +211,20 @@ public partial interface ISearchClient
/// Thrown when the API call was rejected by Algolia
/// Thrown when the client failed to call the endpoint
/// Task of List{SearchResponse{T}}
- Task> SearchForFacetsAsync(IEnumerable requests, SearchStrategy? searchStrategy, RequestOptions options = null, CancellationToken cancellationToken = default);
+ Task> SearchForFacetsAsync(
+ IEnumerable requests,
+ SearchStrategy? searchStrategy,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
+
///
- List SearchForFacets(IEnumerable requests, SearchStrategy? searchStrategy, RequestOptions options = null, CancellationToken cancellationToken = default);
+ List SearchForFacets(
+ IEnumerable requests,
+ SearchStrategy? searchStrategy,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
///
/// Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are untouched.
@@ -143,9 +238,26 @@ public partial interface ISearchClient
/// The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
- Task ReplaceAllObjectsAsync(string indexName, IEnumerable objects, int batchSize = 1000, List scopes = null, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ Task ReplaceAllObjectsAsync(
+ string indexName,
+ IEnumerable objects,
+ int batchSize = 1000,
+ List scopes = null,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
+
///
- ReplaceAllObjectsResponse ReplaceAllObjects(string indexName, IEnumerable objects, int batchSize = 1000, List scopes = null, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ ReplaceAllObjectsResponse ReplaceAllObjects(
+ string indexName,
+ IEnumerable objects,
+ int batchSize = 1000,
+ List scopes = null,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
///
/// Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
@@ -158,9 +270,28 @@ public partial interface ISearchClient
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
///
- Task> ChunkedBatchAsync(string indexName, IEnumerable objects, Action action = Action.AddObject, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ Task> ChunkedBatchAsync(
+ string indexName,
+ IEnumerable objects,
+ Action action = Action.AddObject,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
+
///
- List ChunkedBatch(string indexName, IEnumerable objects, Action action = Action.AddObject, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ List ChunkedBatch(
+ string indexName,
+ IEnumerable objects,
+ Action action = Action.AddObject,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
///
/// Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -172,9 +303,26 @@ public partial interface ISearchClient
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
///
- Task> SaveObjectsAsync(string indexName, IEnumerable objects, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ Task> SaveObjectsAsync(
+ string indexName,
+ IEnumerable objects,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
+
///
- List SaveObjects(string indexName, IEnumerable objects, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ List SaveObjects(
+ string indexName,
+ IEnumerable objects,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
///
/// Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -184,9 +332,22 @@ public partial interface ISearchClient
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
///
- Task> SaveObjectsAsync(string indexName, IEnumerable objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;
+ Task> SaveObjectsAsync(
+ string indexName,
+ IEnumerable objects,
+ RequestOptions options,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
+
///
- List SaveObjects(string indexName, IEnumerable objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;
+ List SaveObjects(
+ string indexName,
+ IEnumerable objects,
+ RequestOptions options,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
///
/// Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
@@ -197,9 +358,24 @@ public partial interface ISearchClient
/// The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
- Task> DeleteObjectsAsync(string indexName, IEnumerable objectIDs, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default);
+ Task> DeleteObjectsAsync(
+ string indexName,
+ IEnumerable objectIDs,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
+
///
- List DeleteObjects(string indexName, IEnumerable objectIDs, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default);
+ List DeleteObjects(
+ string indexName,
+ IEnumerable objectIDs,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ );
///
/// Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -211,9 +387,28 @@ public partial interface ISearchClient
/// The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
/// Add extra http header or query parameters to Algolia.
/// Cancellation Token to cancel the request.
- Task> PartialUpdateObjectsAsync(string indexName, IEnumerable objects, bool createIfNotExists, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ Task> PartialUpdateObjectsAsync(
+ string indexName,
+ IEnumerable objects,
+ bool createIfNotExists,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
+
///
- List PartialUpdateObjects(string indexName, IEnumerable objects, bool createIfNotExists, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
+ List PartialUpdateObjects(
+ string indexName,
+ IEnumerable objects,
+ bool createIfNotExists,
+ bool waitForTasks = false,
+ int batchSize = 1000,
+ RequestOptions options = null,
+ CancellationToken cancellationToken = default
+ )
+ where T : class;
///
/// Helper: Check if an index exists.
@@ -221,6 +416,7 @@ public partial interface ISearchClient
/// The index in which to check.
/// Cancellation Token to cancel the request.
Task IndexExistsAsync(string indexName, CancellationToken cancellationToken = default);
+
///
bool IndexExists(string indexName, CancellationToken cancellationToken = default);
}
@@ -233,36 +429,77 @@ public partial class SearchClient : ISearchClient
public const int DefaultMaxRetries = 50;
///
- public async Task WaitForTaskAsync(string indexName, long taskId, int maxRetries = DefaultMaxRetries,
- Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default)
+ public async Task WaitForTaskAsync(
+ string indexName,
+ long taskId,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ )
{
- return await RetryUntil(async () => await GetTaskAsync(indexName, taskId, requestOptions, ct),
- resp => resp.Status == Models.Search.TaskStatus.Published, maxRetries, timeout, ct).ConfigureAwait(false);
+ return await RetryUntil(
+ async () => await GetTaskAsync(indexName, taskId, requestOptions, ct),
+ resp => resp.Status == Models.Search.TaskStatus.Published,
+ maxRetries,
+ timeout,
+ ct
+ )
+ .ConfigureAwait(false);
}
///
- public GetTaskResponse WaitForTask(string indexName, long taskId, int maxRetries = DefaultMaxRetries,
- Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default) =>
- AsyncHelper.RunSync(() => WaitForTaskAsync(indexName, taskId, maxRetries, timeout, requestOptions, ct));
+ public GetTaskResponse WaitForTask(
+ string indexName,
+ long taskId,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ ) =>
+ AsyncHelper.RunSync(() =>
+ WaitForTaskAsync(indexName, taskId, maxRetries, timeout, requestOptions, ct)
+ );
///
- public async Task WaitForAppTaskAsync(long taskId, int maxRetries = DefaultMaxRetries,
- Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default)
+ public async Task WaitForAppTaskAsync(
+ long taskId,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ )
{
- return await RetryUntil(async () => await GetAppTaskAsync(taskId, requestOptions, ct),
- resp => resp.Status == Models.Search.TaskStatus.Published, maxRetries, timeout, ct).ConfigureAwait(false);
+ return await RetryUntil(
+ async () => await GetAppTaskAsync(taskId, requestOptions, ct),
+ resp => resp.Status == Models.Search.TaskStatus.Published,
+ maxRetries,
+ timeout,
+ ct
+ )
+ .ConfigureAwait(false);
}
///
- public GetTaskResponse WaitForAppTask(long taskId, int maxRetries = DefaultMaxRetries,
- Func timeout = null, RequestOptions requestOptions = null, CancellationToken ct = default) =>
+ public GetTaskResponse WaitForAppTask(
+ long taskId,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ ) =>
AsyncHelper.RunSync(() => WaitForAppTaskAsync(taskId, maxRetries, timeout, requestOptions, ct));
///
- public async Task WaitForApiKeyAsync(string key,
+ public async Task WaitForApiKeyAsync(
+ string key,
ApiKeyOperation operation,
- ApiKey apiKey = default, int maxRetries = DefaultMaxRetries, Func timeout = null,
- RequestOptions requestOptions = null, CancellationToken ct = default)
+ ApiKey apiKey = default,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ )
{
if (operation == ApiKeyOperation.Update)
{
@@ -271,25 +508,32 @@ public async Task WaitForApiKeyAsync(string key,
throw new AlgoliaException("`ApiKey` is required when waiting for an `update` operation.");
}
- return await RetryUntil(() => GetApiKeyAsync(key, requestOptions, ct),
- resp =>
- {
- var apiKeyResponse = new ApiKey
+ return await RetryUntil(
+ () => GetApiKeyAsync(key, requestOptions, ct),
+ resp =>
{
- Acl = resp.Acl,
- Description = resp.Description,
- Indexes = resp.Indexes,
- Referers = resp.Referers,
- Validity = resp.Validity,
- QueryParameters = resp.QueryParameters,
- MaxHitsPerQuery = resp.MaxHitsPerQuery,
- MaxQueriesPerIPPerHour = resp.MaxQueriesPerIPPerHour
- };
- return apiKeyResponse.Equals(apiKey);
- }, maxRetries, timeout, ct).ConfigureAwait(false);
+ var apiKeyResponse = new ApiKey
+ {
+ Acl = resp.Acl,
+ Description = resp.Description,
+ Indexes = resp.Indexes,
+ Referers = resp.Referers,
+ Validity = resp.Validity,
+ QueryParameters = resp.QueryParameters,
+ MaxHitsPerQuery = resp.MaxHitsPerQuery,
+ MaxQueriesPerIPPerHour = resp.MaxQueriesPerIPPerHour,
+ };
+ return apiKeyResponse.Equals(apiKey);
+ },
+ maxRetries,
+ timeout,
+ ct
+ )
+ .ConfigureAwait(false);
}
- return await RetryUntil(async () =>
+ return await RetryUntil(
+ async () =>
{
try
{
@@ -304,95 +548,137 @@ public async Task WaitForApiKeyAsync(string key,
throw;
}
- }, (response) =>
+ },
+ (response) =>
{
return operation switch
{
ApiKeyOperation.Add =>
- // stop either when the key is created or when we don't receive 404
- response is not null,
+ // stop either when the key is created or when we don't receive 404
+ response is not null,
ApiKeyOperation.Delete =>
- // stop when the key is not found
- response is null,
- _ => false
+ // stop when the key is not found
+ response is null,
+ _ => false,
};
},
- maxRetries, timeout, ct);
+ maxRetries,
+ timeout,
+ ct
+ );
}
///
- public GetApiKeyResponse WaitForApiKey(string key, ApiKeyOperation operation, ApiKey apiKey = default,
- int maxRetries = DefaultMaxRetries, Func timeout = null, RequestOptions requestOptions = null,
- CancellationToken ct = default) =>
- AsyncHelper.RunSync(() => WaitForApiKeyAsync(key, operation, apiKey, maxRetries, timeout, requestOptions, ct));
-
+ public GetApiKeyResponse WaitForApiKey(
+ string key,
+ ApiKeyOperation operation,
+ ApiKey apiKey = default,
+ int maxRetries = DefaultMaxRetries,
+ Func timeout = null,
+ RequestOptions requestOptions = null,
+ CancellationToken ct = default
+ ) =>
+ AsyncHelper.RunSync(() =>
+ WaitForApiKeyAsync(key, operation, apiKey, maxRetries, timeout, requestOptions, ct)
+ );
///
- public async Task> BrowseObjectsAsync(string indexName, BrowseParamsObject browseParams,
- RequestOptions requestOptions = null)
+ public async Task> BrowseObjectsAsync(
+ string indexName,
+ BrowseParamsObject browseParams,
+ RequestOptions requestOptions = null
+ )
{
browseParams.HitsPerPage = 1000;
- var all = await CreateIterable>(async prevResp =>
- {
- browseParams.Cursor = prevResp?.Cursor;
- return await BrowseAsync(indexName, new BrowseParams(browseParams), requestOptions);
- }, resp => resp is { Cursor: null }).ConfigureAwait(false);
+ var all = await CreateIterable>(
+ async prevResp =>
+ {
+ browseParams.Cursor = prevResp?.Cursor;
+ return await BrowseAsync(indexName, new BrowseParams(browseParams), requestOptions);
+ },
+ resp => resp is { Cursor: null }
+ )
+ .ConfigureAwait(false);
return all.SelectMany(u => u.Hits);
}
-
///
- public IEnumerable BrowseObjects(string indexName, BrowseParamsObject browseParams,
- RequestOptions requestOptions = null) =>
- AsyncHelper.RunSync(() => BrowseObjectsAsync(indexName, browseParams, requestOptions));
-
+ public IEnumerable BrowseObjects(
+ string indexName,
+ BrowseParamsObject browseParams,
+ RequestOptions requestOptions = null
+ ) => AsyncHelper.RunSync(() => BrowseObjectsAsync(indexName, browseParams, requestOptions));
///
- public async Task> BrowseRulesAsync(string indexName, SearchRulesParams searchRulesParams,
- RequestOptions requestOptions = null)
+ public async Task> BrowseRulesAsync(
+ string indexName,
+ SearchRulesParams searchRulesParams,
+ RequestOptions requestOptions = null
+ )
{
const int hitsPerPage = 1000;
searchRulesParams.HitsPerPage = hitsPerPage;
- var all = await CreateIterable>(async (prevResp) =>
- {
- var page = prevResp?.Item2 ?? 0;
- var searchSynonymsResponse = await SearchRulesAsync(indexName, searchRulesParams, requestOptions);
- return new Tuple(searchSynonymsResponse, page + 1);
- }, resp => resp?.Item1 is { Hits.Count: < hitsPerPage }).ConfigureAwait(false);
+ var all = await CreateIterable>(
+ async (prevResp) =>
+ {
+ var page = prevResp?.Item2 ?? 0;
+ var searchSynonymsResponse = await SearchRulesAsync(
+ indexName,
+ searchRulesParams,
+ requestOptions
+ );
+ return new Tuple(searchSynonymsResponse, page + 1);
+ },
+ resp => resp?.Item1 is { Hits.Count: < hitsPerPage }
+ )
+ .ConfigureAwait(false);
return all.SelectMany(u => u.Item1.Hits);
}
///
- public IEnumerable BrowseRules(string indexName, SearchRulesParams searchRulesParams,
- RequestOptions requestOptions = null) =>
- AsyncHelper.RunSync(() => BrowseRulesAsync(indexName, searchRulesParams, requestOptions));
-
+ public IEnumerable BrowseRules(
+ string indexName,
+ SearchRulesParams searchRulesParams,
+ RequestOptions requestOptions = null
+ ) => AsyncHelper.RunSync(() => BrowseRulesAsync(indexName, searchRulesParams, requestOptions));
///
- public async Task> BrowseSynonymsAsync(string indexName, SearchSynonymsParams synonymsParams,
- RequestOptions requestOptions = null)
+ public async Task> BrowseSynonymsAsync(
+ string indexName,
+ SearchSynonymsParams synonymsParams,
+ RequestOptions requestOptions = null
+ )
{
const int hitsPerPage = 1000;
var page = synonymsParams.Page ?? 0;
synonymsParams.HitsPerPage = hitsPerPage;
- var all = await CreateIterable>(async (prevResp) =>
- {
- var searchSynonymsResponse = await SearchSynonymsAsync(indexName, synonymsParams, requestOptions);
- page = page + 1;
- return new Tuple(searchSynonymsResponse, page);
- }, resp => resp?.Item1 is { Hits.Count: < hitsPerPage }).ConfigureAwait(false);
+ var all = await CreateIterable>(
+ async (prevResp) =>
+ {
+ var searchSynonymsResponse = await SearchSynonymsAsync(
+ indexName,
+ synonymsParams,
+ requestOptions
+ );
+ page = page + 1;
+ return new Tuple(searchSynonymsResponse, page);
+ },
+ resp => resp?.Item1 is { Hits.Count: < hitsPerPage }
+ )
+ .ConfigureAwait(false);
return all.SelectMany(u => u.Item1.Hits);
}
///
- public IEnumerable BrowseSynonyms(string indexName, SearchSynonymsParams synonymsParams,
- RequestOptions requestOptions = null) =>
- AsyncHelper.RunSync(() => BrowseSynonymsAsync(indexName, synonymsParams, requestOptions));
-
+ public IEnumerable BrowseSynonyms(
+ string indexName,
+ SearchSynonymsParams synonymsParams,
+ RequestOptions requestOptions = null
+ ) => AsyncHelper.RunSync(() => BrowseSynonymsAsync(indexName, synonymsParams, requestOptions));
///
public string GenerateSecuredApiKey(string parentApiKey, SecuredApiKeyRestrictions restriction)
@@ -402,7 +688,6 @@ public string GenerateSecuredApiKey(string parentApiKey, SecuredApiKeyRestrictio
return HmacShaHelper.Base64Encode($"{hash}{queryParams}");
}
-
///
public TimeSpan GetSecuredApiKeyRemainingValidity(string securedApiKey)
{
@@ -433,43 +718,69 @@ public TimeSpan GetSecuredApiKeyRemainingValidity(string securedApiKey)
return TimeSpan.FromSeconds(timeStamp - unixTime);
}
-
///
- public async Task>> SearchForHitsAsync(IEnumerable requests,
- SearchStrategy? searchStrategy = null, RequestOptions options = null, CancellationToken cancellationToken = default)
+ public async Task>> SearchForHitsAsync(
+ IEnumerable