Skip to content

Commit

Permalink
feat(clients): helper to switch API key in use (#3616) (generated) [s…
Browse files Browse the repository at this point in the history
…kip ci]

Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
3 people committed Sep 6, 2024
1 parent 2c65a8d commit 663670f
Show file tree
Hide file tree
Showing 338 changed files with 15,106 additions and 2,436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public interface IAbtestingClient
/// </summary>
public partial class AbtestingClient : IAbtestingClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<AbtestingClient> _logger;

/// <summary>
Expand Down Expand Up @@ -382,6 +382,17 @@ public AbtestingClient(AbtestingConfig config, IHttpRequester httpRequester, ILo
}
}

/// <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<ABTestResponse> AddABTestsAsync(AddABTestsRequest addABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ public interface IAnalyticsClient
/// </summary>
public partial class AnalyticsClient : IAnalyticsClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<AnalyticsClient> _logger;

/// <summary>
Expand Down Expand Up @@ -964,6 +964,17 @@ public AnalyticsClient(AnalyticsConfig config, IHttpRequester httpRequester, ILo
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ public interface IIngestionClient
/// </summary>
public partial class IngestionClient : IIngestionClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<IngestionClient> _logger;

/// <summary>
Expand Down Expand Up @@ -2098,6 +2098,17 @@ public IngestionClient(IngestionConfig config, IHttpRequester httpRequester, ILo
}
}

/// <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<AuthenticationCreateResponse> CreateAuthenticationAsync(AuthenticationCreate authenticationCreate, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public interface IInsightsClient
/// </summary>
public partial class InsightsClient : IInsightsClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<InsightsClient> _logger;

/// <summary>
Expand Down Expand Up @@ -244,6 +244,17 @@ public InsightsClient(InsightsConfig config, IHttpRequester httpRequester, ILogg
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public interface IMonitoringClient
/// </summary>
public partial class MonitoringClient : IMonitoringClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<MonitoringClient> _logger;

/// <summary>
Expand Down Expand Up @@ -408,6 +408,17 @@ public MonitoringClient(MonitoringConfig config, IHttpRequester httpRequester, I
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public interface IPersonalizationClient
/// </summary>
public partial class PersonalizationClient : IPersonalizationClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<PersonalizationClient> _logger;

/// <summary>
Expand Down Expand Up @@ -314,6 +314,17 @@ public PersonalizationClient(PersonalizationConfig config, IHttpRequester httpRe
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public interface IQuerySuggestionsClient
/// </summary>
public partial class QuerySuggestionsClient : IQuerySuggestionsClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<QuerySuggestionsClient> _logger;

/// <summary>
Expand Down Expand Up @@ -406,6 +406,17 @@ public QuerySuggestionsClient(QuerySuggestionsConfig config, IHttpRequester http
}
}

/// <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<BaseResponse> CreateConfigAsync(ConfigurationWithIndex configurationWithIndex, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public interface IRecommendClient
/// </summary>
public partial class RecommendClient : IRecommendClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<RecommendClient> _logger;

/// <summary>
Expand Down Expand Up @@ -362,6 +362,17 @@ public RecommendClient(RecommendConfig config, IHttpRequester httpRequester, ILo
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ public partial interface ISearchClient
/// </summary>
public partial class SearchClient : ISearchClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<SearchClient> _logger;

/// <summary>
Expand Down Expand Up @@ -2008,6 +2008,17 @@ public SearchClient(SearchConfig config, IHttpRequester httpRequester, ILoggerFa
}
}

/// <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<AddApiKeyResponse> AddApiKeyAsync(ApiKey apiKey, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public interface IUsageClient
/// </summary>
public partial class UsageClient : IUsageClient
{
private readonly HttpTransport _transport;
internal HttpTransport _transport;
private readonly ILogger<UsageClient> _logger;

/// <summary>
Expand Down Expand Up @@ -258,6 +258,17 @@ public UsageClient(UsageConfig config, IHttpRequester httpRequester, ILoggerFact
}
}

/// <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<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import 'package:algoliasearch/src/model/search_method_params.dart';
import 'package:algoliasearch/src/model/search_responses.dart';

final class SearchClient implements ApiClient {
@override
final String apiKey;

@override
final String appId;

@override
final ClientOptions options;

final RetryStrategy _retryStrategy;

SearchClient({
required this.appId,
required this.apiKey,
required String appId,
required String apiKey,
this.options = const ClientOptions(),
}) : _retryStrategy = RetryStrategy.create(
segment:
Expand All @@ -46,6 +40,12 @@ final class SearchClient implements ApiClient {
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
}

/// Allows to switch the API key used to authenticate requests.
@override
void setClientApiKey({required String apiKey}) {
_retryStrategy.requester.setClientApiKey(apiKey);
}

/// This method allow you to send requests to the Algolia REST API.
///
/// Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import 'package:algolia_client_insights/src/model/events_response.dart';
import 'package:algolia_client_insights/src/model/insights_events.dart';

final class InsightsClient implements ApiClient {
@override
final String apiKey;

@override
final String appId;

@override
final ClientOptions options;

Expand All @@ -22,8 +16,8 @@ final class InsightsClient implements ApiClient {
final RetryStrategy _retryStrategy;

InsightsClient({
required this.appId,
required this.apiKey,
required String appId,
required String apiKey,
this.options = const ClientOptions(),
this.region,
}) : _retryStrategy = RetryStrategy.create(
Expand All @@ -47,6 +41,12 @@ final class InsightsClient implements ApiClient {
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
}

/// Allows to switch the API key used to authenticate requests.
@override
void setClientApiKey({required String apiKey}) {
_retryStrategy.requester.setClientApiKey(apiKey);
}

/// This method allow you to send requests to the Algolia REST API.
///
/// Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ import 'package:algolia_client_recommend/src/model/search_recommend_rules_params
import 'package:algolia_client_recommend/src/model/search_recommend_rules_response.dart';

final class RecommendClient implements ApiClient {
@override
final String apiKey;

@override
final String appId;

@override
final ClientOptions options;

final RetryStrategy _retryStrategy;

RecommendClient({
required this.appId,
required this.apiKey,
required String appId,
required String apiKey,
this.options = const ClientOptions(),
}) : _retryStrategy = RetryStrategy.create(
segment: AgentSegment(value: "Recommend", version: packageVersion),
Expand All @@ -49,6 +43,12 @@ final class RecommendClient implements ApiClient {
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
}

/// Allows to switch the API key used to authenticate requests.
@override
void setClientApiKey({required String apiKey}) {
_retryStrategy.requester.setClientApiKey(apiKey);
}

/// This method allow you to send requests to the Algolia REST API.
///
/// Parameters:
Expand Down
Loading

0 comments on commit 663670f

Please sign in to comment.