Skip to content

Commit

Permalink
Merge branch 'algolia:main' into feat/add-chopper-requester-package
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse authored Jan 28, 2025
2 parents fbd6b5d + de504c7 commit f07babe
Show file tree
Hide file tree
Showing 2,013 changed files with 234,628 additions and 30,980 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
'automation-custom/no-big-int': 'error',
'automation-custom/no-final-dot': 'error',
'automation-custom/single-quote-ref': 'error',
'automation-custom/has-type': 'error',
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.13.0
22.13.1
15 changes: 15 additions & 0 deletions clients/algoliasearch-client-csharp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [7.13.0](https://github.com/algolia/algoliasearch-client-csharp/compare/7.12.0...7.13.0)

- [5aa57630d6](https://github.com/algolia/api-clients-automation/commit/5aa57630d6) feat(specs): only use shortname in the source input ([#4287](https://github.com/algolia/api-clients-automation/pull/4287)) by [@millotp](https://github.com/millotp/)
- [1e847f4caf](https://github.com/algolia/api-clients-automation/commit/1e847f4caf) fix(specs): move customRanking and keepDiacriticsOnCharacters to indexSettings ([#4324](https://github.com/algolia/api-clients-automation/pull/4324)) by [@millotp](https://github.com/millotp/)
- [57d528a481](https://github.com/algolia/api-clients-automation/commit/57d528a481) feat(clients): endpoint level timeout part 2 ([#4318](https://github.com/algolia/api-clients-automation/pull/4318)) by [@Fluf22](https://github.com/Fluf22/)
- [58cc5449f5](https://github.com/algolia/api-clients-automation/commit/58cc5449f5) fix(specs): optionalFilters additional explanation ([#4353](https://github.com/algolia/api-clients-automation/pull/4353)) by [@kai687](https://github.com/kai687/)
- [700441942e](https://github.com/algolia/api-clients-automation/commit/700441942e) fix(specs): deprecate task v1 ([#4327](https://github.com/algolia/api-clients-automation/pull/4327)) by [@millotp](https://github.com/millotp/)
- [3b129e01df](https://github.com/algolia/api-clients-automation/commit/3b129e01df) fix(specs): ingestion expected and received events type ([#4356](https://github.com/algolia/api-clients-automation/pull/4356)) by [@shortcuts](https://github.com/shortcuts/)
- [22167b8e68](https://github.com/algolia/api-clients-automation/commit/22167b8e68) fix(specs): extend Analytics descriptions ([#4360](https://github.com/algolia/api-clients-automation/pull/4360)) by [@gazconroy](https://github.com/gazconroy/)
- [5b14906c1e](https://github.com/algolia/api-clients-automation/commit/5b14906c1e) fix(specs): remove the processing outcome ([#4359](https://github.com/algolia/api-clients-automation/pull/4359)) by [@millotp](https://github.com/millotp/)
- [952639f0fb](https://github.com/algolia/api-clients-automation/commit/952639f0fb) fix(specs): adjust style for banner descriptions ([#4362](https://github.com/algolia/api-clients-automation/pull/4362)) by [@kai687](https://github.com/kai687/)
- [4ae9ccd89f](https://github.com/algolia/api-clients-automation/commit/4ae9ccd89f) chore(deps): dependencies 2025-01-20 ([#4365](https://github.com/algolia/api-clients-automation/pull/4365)) by [@algolia-bot](https://github.com/algolia-bot/)
- [83f188d333](https://github.com/algolia/api-clients-automation/commit/83f188d333) feat(specs): rename composition to composition-full (private) and add composition (public) ([#4357](https://github.com/algolia/api-clients-automation/pull/4357)) by [@e-krebs](https://github.com/e-krebs/)
- [eb83e3bc8a](https://github.com/algolia/api-clients-automation/commit/eb83e3bc8a) docs: lot of guides ([#4355](https://github.com/algolia/api-clients-automation/pull/4355)) by [@shortcuts](https://github.com/shortcuts/)

## [7.12.0](https://github.com/algolia/algoliasearch-client-csharp/compare/7.11.2...7.12.0)

- [b569646304](https://github.com/algolia/api-clients-automation/commit/b569646304) fix(specs): drop singer from ingestion specs ([#4281](https://github.com/algolia/api-clients-automation/pull/4281)) by [@shortcuts](https://github.com/shortcuts/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RepositoryUrl>https://github.com/algolia/algoliasearch-client-csharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
<Version>7.12.0</Version>
<Version>7.13.0</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class AbtestingConfig : AlgoliaConfig
/// <param name="appId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
/// <param name="region">Targeted region (optional)</param>
public AbtestingConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Abtesting", "7.12.0")
public AbtestingConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Abtesting", "7.13.0")
{
DefaultHosts = GetDefaultHosts(region);
Compression = CompressionType.None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class AnalyticsConfig : AlgoliaConfig
/// <param name="appId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
/// <param name="region">Targeted region (optional)</param>
public AnalyticsConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Analytics", "7.12.0")
public AnalyticsConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Analytics", "7.13.0")
{
DefaultHosts = GetDefaultHosts(region);
Compression = CompressionType.None;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
//
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
//
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Algolia.Search.Models.Composition;
using Algolia.Search.Transport;
using Algolia.Search.Http;
using Algolia.Search.Utils;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

namespace Algolia.Search.Clients;


/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface ICompositionClient
{
/// <summary>
/// Runs a query on a single composition and returns matching results.
/// </summary>
///
/// Required API Key ACLs:
/// - search
/// <param name="compositionID">Unique Composition ObjectID.</param>
/// <param name="requestBody"></param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>Task of SearchResponse{T}</returns>
Task<SearchResponse<T>> SearchAsync<T>(string compositionID, RequestBody requestBody, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Runs a query on a single composition and returns matching results. (Synchronous version)
/// </summary>
///
/// Required API Key ACLs:
/// - search
/// <param name="compositionID">Unique Composition ObjectID.</param>
/// <param name="requestBody"></param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>SearchResponse{T}</returns>
SearchResponse<T> Search<T>(string compositionID, RequestBody requestBody, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**.
/// </summary>
///
/// Required API Key ACLs:
/// - search
/// <param name="compositionID">Unique Composition ObjectID.</param>
/// <param name="facetName">Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. </param>
/// <param name="searchForFacetValuesRequest"> (optional)</param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>Task of SearchForFacetValuesResponse</returns>
Task<SearchForFacetValuesResponse> SearchForFacetValuesAsync(string compositionID, string facetName, SearchForFacetValuesRequest searchForFacetValuesRequest = default, RequestOptions options = null, CancellationToken cancellationToken = default);

/// <summary>
/// Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**. (Synchronous version)
/// </summary>
///
/// Required API Key ACLs:
/// - search
/// <param name="compositionID">Unique Composition ObjectID.</param>
/// <param name="facetName">Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. </param>
/// <param name="searchForFacetValuesRequest"> (optional)</param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
/// <returns>SearchForFacetValuesResponse</returns>
SearchForFacetValuesResponse SearchForFacetValues(string compositionID, string facetName, SearchForFacetValuesRequest searchForFacetValuesRequest = default, RequestOptions options = null, CancellationToken cancellationToken = default);

}



/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class CompositionClient : ICompositionClient
{
internal HttpTransport _transport;
private readonly ILogger<CompositionClient> _logger;

/// <summary>
/// Create a new Composition client for the given appID and apiKey.
/// </summary>
/// <param name="applicationId">Your application</param>
/// <param name="apiKey">Your API key</param>
/// <param name="loggerFactory">Logger factory</param>

public CompositionClient(string applicationId, string apiKey, ILoggerFactory loggerFactory = null) : this(new CompositionConfig(applicationId, apiKey), new AlgoliaHttpRequester(loggerFactory), loggerFactory)
{
}

/// <summary>
/// Initialize a client with custom config
/// </summary>
/// <param name="config">Algolia configuration</param>
/// <param name="loggerFactory">Logger factory</param>
public CompositionClient(CompositionConfig config, ILoggerFactory loggerFactory = null) : this(config, new AlgoliaHttpRequester(loggerFactory), loggerFactory)
{
}

/// <summary>
/// Initialize the client with custom config and custom Requester
/// </summary>
/// <param name="config">Algolia Config</param>
/// <param name="httpRequester">Your Http requester implementation of <see cref="IHttpRequester"/></param>
/// <param name="loggerFactory">Logger factory</param>
public CompositionClient(CompositionConfig config, IHttpRequester httpRequester, ILoggerFactory loggerFactory = null)
{
if (httpRequester == null)
{
throw new ArgumentException("An httpRequester is required");
}
if (config == null)
{
throw new ArgumentException("A config is required");
}
if (string.IsNullOrWhiteSpace(config.AppId))
{
throw new ArgumentException("`AppId` is missing.");
}
if (string.IsNullOrWhiteSpace(config.ApiKey))
{
throw new ArgumentException("`ApiKey` is missing.");
}

var factory = loggerFactory ?? NullLoggerFactory.Instance;
_transport = new HttpTransport(config, httpRequester, factory);
_logger = factory.CreateLogger<CompositionClient>();

if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information))
{
_logger.LogInformation("Algolia Composition client is initialized.");
}
}

/// <summary>
/// Helper to switch the API key sent with each request
/// </summary>
/// <param name="apiKey">Your new API Key</param>
/// <returns></returns>
public void SetClientApiKey(string apiKey)
{
_transport._algoliaConfig.SetClientApiKey(apiKey);
}



/// <inheritdoc />
public async Task<SearchResponse<T>> SearchAsync<T>(string compositionID, RequestBody requestBody, RequestOptions options = null, CancellationToken cancellationToken = default)
{

if (compositionID == null)
throw new ArgumentException("Parameter `compositionID` is required when calling `Search`.");


if (requestBody == null)
throw new ArgumentException("Parameter `requestBody` is required when calling `Search`.");

var requestOptions = new InternalRequestOptions(options);

requestOptions.PathParameters.Add("compositionID", QueryStringHelper.ParameterToString(compositionID));

requestOptions.Data = requestBody;
requestOptions.UseReadTransporter = true;
return await _transport.ExecuteRequestAsync<SearchResponse<T>>(new HttpMethod("POST"), "/1/compositions/{compositionID}/run", requestOptions, cancellationToken).ConfigureAwait(false);
}


/// <inheritdoc />
public SearchResponse<T> Search<T>(string compositionID, RequestBody requestBody, RequestOptions options = null, CancellationToken cancellationToken = default) =>
AsyncHelper.RunSync(() => SearchAsync<T>(compositionID, requestBody, options, cancellationToken));


/// <inheritdoc />
public async Task<SearchForFacetValuesResponse> SearchForFacetValuesAsync(string compositionID, string facetName, SearchForFacetValuesRequest searchForFacetValuesRequest = default, RequestOptions options = null, CancellationToken cancellationToken = default)
{

if (compositionID == null)
throw new ArgumentException("Parameter `compositionID` is required when calling `SearchForFacetValues`.");


if (facetName == null)
throw new ArgumentException("Parameter `facetName` is required when calling `SearchForFacetValues`.");

var requestOptions = new InternalRequestOptions(options);

requestOptions.PathParameters.Add("compositionID", QueryStringHelper.ParameterToString(compositionID));
requestOptions.PathParameters.Add("facetName", QueryStringHelper.ParameterToString(facetName));

requestOptions.Data = searchForFacetValuesRequest;
requestOptions.UseReadTransporter = true;
return await _transport.ExecuteRequestAsync<SearchForFacetValuesResponse>(new HttpMethod("POST"), "/1/compositions/{compositionID}/facets/{facetName}/query", requestOptions, cancellationToken).ConfigureAwait(false);
}


/// <inheritdoc />
public SearchForFacetValuesResponse SearchForFacetValues(string compositionID, string facetName, SearchForFacetValuesRequest searchForFacetValuesRequest = default, RequestOptions options = null, CancellationToken cancellationToken = default) =>
AsyncHelper.RunSync(() => SearchForFacetValuesAsync(compositionID, facetName, searchForFacetValuesRequest, options, cancellationToken));

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Composition API
*
* Composition API.
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://github.com/openapitools/openapi-generator.git
*/


using System;
using System.Collections.Generic;
using Algolia.Search.Models.Common;
using Algolia.Search.Transport;
using Algolia.Search.Utils;

namespace Algolia.Search.Clients;

/// <summary>
/// Composition client configuration
/// </summary>
public sealed class CompositionConfig : AlgoliaConfig
{
/// <summary>
/// The configuration of the Composition client
/// A client should have it's own configuration ie on configuration per client instance
/// </summary>
/// <param name="appId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
public CompositionConfig(string appId, string apiKey) : base(appId, apiKey, "Composition", "7.13.0")
{
DefaultHosts = GetDefaultHosts(appId);
Compression = CompressionType.None;
ReadTimeout = TimeSpan.FromMilliseconds(5000);
WriteTimeout = TimeSpan.FromMilliseconds(30000);
ConnectTimeout = TimeSpan.FromMilliseconds(2000);
}
private static List<StatefulHost> GetDefaultHosts(string appId)
{
var hosts = new List<StatefulHost>
{
new()
{
Url = $"{appId}-dsn.algolia.net",
Up = true,
LastUse = DateTime.UtcNow,
Accept = CallType.Read
},
new()
{
Url = $"{appId}.algolia.net", Up = true, LastUse = DateTime.UtcNow, Accept = CallType.Write,
}
};

var commonHosts = new List<StatefulHost>
{
new()
{
Url = $"{appId}-1.algolianet.com",
Up = true,
LastUse = DateTime.UtcNow,
Accept = CallType.Read | CallType.Write,
},
new()
{
Url = $"{appId}-2.algolianet.com",
Up = true,
LastUse = DateTime.UtcNow,
Accept = CallType.Read | CallType.Write,
},
new()
{
Url = $"{appId}-3.algolianet.com",
Up = true,
LastUse = DateTime.UtcNow,
Accept = CallType.Read | CallType.Write,
}
}.Shuffle();

hosts.AddRange(commonHosts);
return hosts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class IngestionConfig : AlgoliaConfig
/// <param name="appId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
/// <param name="region">Targeted region </param>
public IngestionConfig(string appId, string apiKey, string region) : base(appId, apiKey, "Ingestion", "7.12.0")
public IngestionConfig(string appId, string apiKey, string region) : base(appId, apiKey, "Ingestion", "7.13.0")
{
DefaultHosts = GetDefaultHosts(region);
Compression = CompressionType.None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class InsightsConfig : AlgoliaConfig
/// <param name="appId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
/// <param name="region">Targeted region (optional)</param>
public InsightsConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Insights", "7.12.0")
public InsightsConfig(string appId, string apiKey, string region = null) : base(appId, apiKey, "Insights", "7.13.0")
{
DefaultHosts = GetDefaultHosts(region);
Compression = CompressionType.None;
Expand Down
Loading

0 comments on commit f07babe

Please sign in to comment.