Skip to content

Commit 663670f

Browse files
algolia-botFluf22millotp
committed
feat(clients): helper to switch API key in use (#3616) (generated) [skip ci]
Co-authored-by: Thomas Raffray <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 2c65a8d commit 663670f

File tree

338 files changed

+15106
-2436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

338 files changed

+15106
-2436
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Clients/AbtestingClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public interface IAbtestingClient
324324
/// </summary>
325325
public partial class AbtestingClient : IAbtestingClient
326326
{
327-
private readonly HttpTransport _transport;
327+
internal HttpTransport _transport;
328328
private readonly ILogger<AbtestingClient> _logger;
329329

330330
/// <summary>
@@ -382,6 +382,17 @@ public AbtestingClient(AbtestingConfig config, IHttpRequester httpRequester, ILo
382382
}
383383
}
384384

385+
/// <summary>
386+
/// Helper to switch the API key sent with each request
387+
/// </summary>
388+
/// <param name="apiKey">Your new API Key</param>
389+
/// <returns></returns>
390+
public void SetClientApiKey(string apiKey)
391+
{
392+
_transport._algoliaConfig.SetClientApiKey(apiKey);
393+
}
394+
395+
385396

386397
/// <inheritdoc />
387398
public async Task<ABTestResponse> AddABTestsAsync(AddABTestsRequest addABTestsRequest, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/AnalyticsClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ public interface IAnalyticsClient
906906
/// </summary>
907907
public partial class AnalyticsClient : IAnalyticsClient
908908
{
909-
private readonly HttpTransport _transport;
909+
internal HttpTransport _transport;
910910
private readonly ILogger<AnalyticsClient> _logger;
911911

912912
/// <summary>
@@ -964,6 +964,17 @@ public AnalyticsClient(AnalyticsConfig config, IHttpRequester httpRequester, ILo
964964
}
965965
}
966966

967+
/// <summary>
968+
/// Helper to switch the API key sent with each request
969+
/// </summary>
970+
/// <param name="apiKey">Your new API Key</param>
971+
/// <returns></returns>
972+
public void SetClientApiKey(string apiKey)
973+
{
974+
_transport._algoliaConfig.SetClientApiKey(apiKey);
975+
}
976+
977+
967978

968979
/// <inheritdoc />
969980
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/IngestionClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ public interface IIngestionClient
20402040
/// </summary>
20412041
public partial class IngestionClient : IIngestionClient
20422042
{
2043-
private readonly HttpTransport _transport;
2043+
internal HttpTransport _transport;
20442044
private readonly ILogger<IngestionClient> _logger;
20452045

20462046
/// <summary>
@@ -2098,6 +2098,17 @@ public IngestionClient(IngestionConfig config, IHttpRequester httpRequester, ILo
20982098
}
20992099
}
21002100

2101+
/// <summary>
2102+
/// Helper to switch the API key sent with each request
2103+
/// </summary>
2104+
/// <param name="apiKey">Your new API Key</param>
2105+
/// <returns></returns>
2106+
public void SetClientApiKey(string apiKey)
2107+
{
2108+
_transport._algoliaConfig.SetClientApiKey(apiKey);
2109+
}
2110+
2111+
21012112

21022113
/// <inheritdoc />
21032114
public async Task<AuthenticationCreateResponse> CreateAuthenticationAsync(AuthenticationCreate authenticationCreate, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/InsightsClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public interface IInsightsClient
186186
/// </summary>
187187
public partial class InsightsClient : IInsightsClient
188188
{
189-
private readonly HttpTransport _transport;
189+
internal HttpTransport _transport;
190190
private readonly ILogger<InsightsClient> _logger;
191191

192192
/// <summary>
@@ -244,6 +244,17 @@ public InsightsClient(InsightsConfig config, IHttpRequester httpRequester, ILogg
244244
}
245245
}
246246

247+
/// <summary>
248+
/// Helper to switch the API key sent with each request
249+
/// </summary>
250+
/// <param name="apiKey">Your new API Key</param>
251+
/// <returns></returns>
252+
public void SetClientApiKey(string apiKey)
253+
{
254+
_transport._algoliaConfig.SetClientApiKey(apiKey);
255+
}
256+
257+
247258

248259
/// <inheritdoc />
249260
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/MonitoringClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public interface IMonitoringClient
350350
/// </summary>
351351
public partial class MonitoringClient : IMonitoringClient
352352
{
353-
private readonly HttpTransport _transport;
353+
internal HttpTransport _transport;
354354
private readonly ILogger<MonitoringClient> _logger;
355355

356356
/// <summary>
@@ -408,6 +408,17 @@ public MonitoringClient(MonitoringConfig config, IHttpRequester httpRequester, I
408408
}
409409
}
410410

411+
/// <summary>
412+
/// Helper to switch the API key sent with each request
413+
/// </summary>
414+
/// <param name="apiKey">Your new API Key</param>
415+
/// <returns></returns>
416+
public void SetClientApiKey(string apiKey)
417+
{
418+
_transport._algoliaConfig.SetClientApiKey(apiKey);
419+
}
420+
421+
411422

412423
/// <inheritdoc />
413424
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/PersonalizationClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public interface IPersonalizationClient
256256
/// </summary>
257257
public partial class PersonalizationClient : IPersonalizationClient
258258
{
259-
private readonly HttpTransport _transport;
259+
internal HttpTransport _transport;
260260
private readonly ILogger<PersonalizationClient> _logger;
261261

262262
/// <summary>
@@ -314,6 +314,17 @@ public PersonalizationClient(PersonalizationConfig config, IHttpRequester httpRe
314314
}
315315
}
316316

317+
/// <summary>
318+
/// Helper to switch the API key sent with each request
319+
/// </summary>
320+
/// <param name="apiKey">Your new API Key</param>
321+
/// <returns></returns>
322+
public void SetClientApiKey(string apiKey)
323+
{
324+
_transport._algoliaConfig.SetClientApiKey(apiKey);
325+
}
326+
327+
317328

318329
/// <inheritdoc />
319330
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/QuerySuggestionsClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public interface IQuerySuggestionsClient
348348
/// </summary>
349349
public partial class QuerySuggestionsClient : IQuerySuggestionsClient
350350
{
351-
private readonly HttpTransport _transport;
351+
internal HttpTransport _transport;
352352
private readonly ILogger<QuerySuggestionsClient> _logger;
353353

354354
/// <summary>
@@ -406,6 +406,17 @@ public QuerySuggestionsClient(QuerySuggestionsConfig config, IHttpRequester http
406406
}
407407
}
408408

409+
/// <summary>
410+
/// Helper to switch the API key sent with each request
411+
/// </summary>
412+
/// <param name="apiKey">Your new API Key</param>
413+
/// <returns></returns>
414+
public void SetClientApiKey(string apiKey)
415+
{
416+
_transport._algoliaConfig.SetClientApiKey(apiKey);
417+
}
418+
419+
409420

410421
/// <inheritdoc />
411422
public async Task<BaseResponse> CreateConfigAsync(ConfigurationWithIndex configurationWithIndex, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/RecommendClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public interface IRecommendClient
304304
/// </summary>
305305
public partial class RecommendClient : IRecommendClient
306306
{
307-
private readonly HttpTransport _transport;
307+
internal HttpTransport _transport;
308308
private readonly ILogger<RecommendClient> _logger;
309309

310310
/// <summary>
@@ -362,6 +362,17 @@ public RecommendClient(RecommendConfig config, IHttpRequester httpRequester, ILo
362362
}
363363
}
364364

365+
/// <summary>
366+
/// Helper to switch the API key sent with each request
367+
/// </summary>
368+
/// <param name="apiKey">Your new API Key</param>
369+
/// <returns></returns>
370+
public void SetClientApiKey(string apiKey)
371+
{
372+
_transport._algoliaConfig.SetClientApiKey(apiKey);
373+
}
374+
375+
365376

366377
/// <inheritdoc />
367378
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/SearchClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ public partial interface ISearchClient
19501950
/// </summary>
19511951
public partial class SearchClient : ISearchClient
19521952
{
1953-
private readonly HttpTransport _transport;
1953+
internal HttpTransport _transport;
19541954
private readonly ILogger<SearchClient> _logger;
19551955

19561956
/// <summary>
@@ -2008,6 +2008,17 @@ public SearchClient(SearchConfig config, IHttpRequester httpRequester, ILoggerFa
20082008
}
20092009
}
20102010

2011+
/// <summary>
2012+
/// Helper to switch the API key sent with each request
2013+
/// </summary>
2014+
/// <param name="apiKey">Your new API Key</param>
2015+
/// <returns></returns>
2016+
public void SetClientApiKey(string apiKey)
2017+
{
2018+
_transport._algoliaConfig.SetClientApiKey(apiKey);
2019+
}
2020+
2021+
20112022

20122023
/// <inheritdoc />
20132024
public async Task<AddApiKeyResponse> AddApiKeyAsync(ApiKey apiKey, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-csharp/algoliasearch/Clients/UsageClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public interface IUsageClient
200200
/// </summary>
201201
public partial class UsageClient : IUsageClient
202202
{
203-
private readonly HttpTransport _transport;
203+
internal HttpTransport _transport;
204204
private readonly ILogger<UsageClient> _logger;
205205

206206
/// <summary>
@@ -258,6 +258,17 @@ public UsageClient(UsageConfig config, IHttpRequester httpRequester, ILoggerFact
258258
}
259259
}
260260

261+
/// <summary>
262+
/// Helper to switch the API key sent with each request
263+
/// </summary>
264+
/// <param name="apiKey">Your new API Key</param>
265+
/// <returns></returns>
266+
public void SetClientApiKey(string apiKey)
267+
{
268+
_transport._algoliaConfig.SetClientApiKey(apiKey);
269+
}
270+
271+
261272

262273
/// <inheritdoc />
263274
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)

clients/algoliasearch-client-dart/packages/algoliasearch/lib/src/api/search_client.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@ import 'package:algoliasearch/src/model/search_method_params.dart';
1010
import 'package:algoliasearch/src/model/search_responses.dart';
1111

1212
final class SearchClient implements ApiClient {
13-
@override
14-
final String apiKey;
15-
16-
@override
17-
final String appId;
18-
1913
@override
2014
final ClientOptions options;
2115

2216
final RetryStrategy _retryStrategy;
2317

2418
SearchClient({
25-
required this.appId,
26-
required this.apiKey,
19+
required String appId,
20+
required String apiKey,
2721
this.options = const ClientOptions(),
2822
}) : _retryStrategy = RetryStrategy.create(
2923
segment:
@@ -46,6 +40,12 @@ final class SearchClient implements ApiClient {
4640
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
4741
}
4842

43+
/// Allows to switch the API key used to authenticate requests.
44+
@override
45+
void setClientApiKey({required String apiKey}) {
46+
_retryStrategy.requester.setClientApiKey(apiKey);
47+
}
48+
4949
/// This method allow you to send requests to the Algolia REST API.
5050
///
5151
/// Parameters:

clients/algoliasearch-client-dart/packages/client_insights/lib/src/api/insights_client.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import 'package:algolia_client_insights/src/model/events_response.dart';
88
import 'package:algolia_client_insights/src/model/insights_events.dart';
99

1010
final class InsightsClient implements ApiClient {
11-
@override
12-
final String apiKey;
13-
14-
@override
15-
final String appId;
16-
1711
@override
1812
final ClientOptions options;
1913

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

2418
InsightsClient({
25-
required this.appId,
26-
required this.apiKey,
19+
required String appId,
20+
required String apiKey,
2721
this.options = const ClientOptions(),
2822
this.region,
2923
}) : _retryStrategy = RetryStrategy.create(
@@ -47,6 +41,12 @@ final class InsightsClient implements ApiClient {
4741
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
4842
}
4943

44+
/// Allows to switch the API key used to authenticate requests.
45+
@override
46+
void setClientApiKey({required String apiKey}) {
47+
_retryStrategy.requester.setClientApiKey(apiKey);
48+
}
49+
5050
/// This method allow you to send requests to the Algolia REST API.
5151
///
5252
/// Parameters:

clients/algoliasearch-client-dart/packages/client_recommend/lib/src/api/recommend_client.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ import 'package:algolia_client_recommend/src/model/search_recommend_rules_params
1414
import 'package:algolia_client_recommend/src/model/search_recommend_rules_response.dart';
1515

1616
final class RecommendClient implements ApiClient {
17-
@override
18-
final String apiKey;
19-
20-
@override
21-
final String appId;
22-
2317
@override
2418
final ClientOptions options;
2519

2620
final RetryStrategy _retryStrategy;
2721

2822
RecommendClient({
29-
required this.appId,
30-
required this.apiKey,
23+
required String appId,
24+
required String apiKey,
3125
this.options = const ClientOptions(),
3226
}) : _retryStrategy = RetryStrategy.create(
3327
segment: AgentSegment(value: "Recommend", version: packageVersion),
@@ -49,6 +43,12 @@ final class RecommendClient implements ApiClient {
4943
assert(apiKey.isNotEmpty, '`apiKey` is missing.');
5044
}
5145

46+
/// Allows to switch the API key used to authenticate requests.
47+
@override
48+
void setClientApiKey({required String apiKey}) {
49+
_retryStrategy.requester.setClientApiKey(apiKey);
50+
}
51+
5252
/// This method allow you to send requests to the Algolia REST API.
5353
///
5454
/// Parameters:

0 commit comments

Comments
 (0)