Skip to content

Commit 394cf60

Browse files
chore: generated code for commit 68ad731. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 68ad731 commit 394cf60

File tree

21 files changed

+123
-102
lines changed

21 files changed

+123
-102
lines changed

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/AbtestingClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ public AbtestingClient(
5858

5959
private static List<StatefulHost> getDefaultHosts(String region) {
6060
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
61+
62+
String url = region == null
63+
? "analytics.algolia.com"
64+
: "analytics.{region}.algolia.com".replace("{region}", region);
65+
6166
hosts.add(
62-
new StatefulHost(
63-
"analytics." + (region == null ? "" : region + ".") + "algolia.com",
64-
"https",
65-
EnumSet.of(CallType.READ, CallType.WRITE)
66-
)
67+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6768
);
6869
return hosts;
6970
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/AnalyticsClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ public AnalyticsClient(
5858

5959
private static List<StatefulHost> getDefaultHosts(String region) {
6060
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
61+
62+
String url = region == null
63+
? "analytics.algolia.com"
64+
: "analytics.{region}.algolia.com".replace("{region}", region);
65+
6166
hosts.add(
62-
new StatefulHost(
63-
"analytics." + (region == null ? "" : region + ".") + "algolia.com",
64-
"https",
65-
EnumSet.of(CallType.READ, CallType.WRITE)
66-
)
67+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6768
);
6869
return hosts;
6970
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/InsightsClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ public InsightsClient(
5858

5959
private static List<StatefulHost> getDefaultHosts(String region) {
6060
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
61+
62+
String url = region == null
63+
? "insights.algolia.io"
64+
: "insights.{region}.algolia.io".replace("{region}", region);
65+
6166
hosts.add(
62-
new StatefulHost(
63-
"insights." + (region == null ? "" : region + ".") + "algolia.io",
64-
"https",
65-
EnumSet.of(CallType.READ, CallType.WRITE)
66-
)
67+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6768
);
6869
return hosts;
6970
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/PersonalizationClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public PersonalizationClient(
5858

5959
private static List<StatefulHost> getDefaultHosts(String region) {
6060
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
61+
62+
String url =
63+
"personalization.{region}.algolia.com".replace("{region}", region);
64+
6165
hosts.add(
62-
new StatefulHost(
63-
"personalization." + region + "algolia.com",
64-
"https",
65-
EnumSet.of(CallType.READ, CallType.WRITE)
66-
)
66+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6767
);
6868
return hosts;
6969
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/PredictClient.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@
2121

2222
public class PredictClient extends ApiClient {
2323

24-
public PredictClient(String appId, String apiKey) {
25-
this(appId, apiKey, new HttpRequester(getDefaultHosts()), null);
24+
public PredictClient(String appId, String apiKey, String region) {
25+
this(appId, apiKey, new HttpRequester(getDefaultHosts(region)), null);
2626
}
2727

2828
public PredictClient(
2929
String appId,
3030
String apiKey,
31+
String region,
3132
UserAgent.Segment[] userAgentSegments
3233
) {
3334
this(
3435
appId,
3536
apiKey,
36-
new HttpRequester(getDefaultHosts()),
37+
new HttpRequester(getDefaultHosts(region)),
3738
userAgentSegments
3839
);
3940
}
@@ -51,14 +52,14 @@ public PredictClient(
5152
super(appId, apiKey, requester, "Predict", userAgentSegments);
5253
}
5354

54-
private static List<StatefulHost> getDefaultHosts() {
55+
private static List<StatefulHost> getDefaultHosts(String region) {
5556
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
57+
58+
String url =
59+
"predict-api-432xa6wemq-{region}.a.run.app".replace("{region}", region);
60+
5661
hosts.add(
57-
new StatefulHost(
58-
"predict-api-432xa6wemq-ew.a.run.app",
59-
"https",
60-
EnumSet.of(CallType.READ, CallType.WRITE)
61-
)
62+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6263
);
6364
return hosts;
6465
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/QuerySuggestionsClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public QuerySuggestionsClient(
5858

5959
private static List<StatefulHost> getDefaultHosts(String region) {
6060
List<StatefulHost> hosts = new ArrayList<StatefulHost>();
61+
62+
String url =
63+
"query-suggestions.{region}.algolia.com".replace("{region}", region);
64+
6165
hosts.add(
62-
new StatefulHost(
63-
"query-suggestions." + region + "algolia.com",
64-
"https",
65-
EnumSet.of(CallType.READ, CallType.WRITE)
66-
)
66+
new StatefulHost(url, "https", EnumSet.of(CallType.READ, CallType.WRITE))
6767
);
6868
return hosts;
6969
}

clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingClient.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ export const apiClientVersion = '0.2.0';
2323
export type Region = 'de' | 'us';
2424

2525
function getDefaultHosts(region?: Region): Host[] {
26-
const regionHost = region ? `.${region}.` : '.';
26+
const url = !region
27+
? 'analytics.algolia.com'
28+
: 'analytics.{region}.algolia.com'.replace('{region}', region);
2729

28-
return [
29-
{
30-
url: `analytics${regionHost}algolia.com`,
31-
accept: 'readWrite',
32-
protocol: 'https',
33-
},
34-
];
30+
return [{ url, accept: 'readWrite', protocol: 'https' }];
3531
}
3632

3733
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsClient.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ export const apiClientVersion = '0.2.0';
3838
export type Region = 'de' | 'us';
3939

4040
function getDefaultHosts(region?: Region): Host[] {
41-
const regionHost = region ? `.${region}.` : '.';
41+
const url = !region
42+
? 'analytics.algolia.com'
43+
: 'analytics.{region}.algolia.com'.replace('{region}', region);
4244

43-
return [
44-
{
45-
url: `analytics${regionHost}algolia.com`,
46-
accept: 'readWrite',
47-
protocol: 'https',
48-
},
49-
];
45+
return [{ url, accept: 'readWrite', protocol: 'https' }];
5046
}
5147

5248
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-javascript/packages/client-insights/src/insightsClient.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ export const apiClientVersion = '0.2.0';
2121
export type Region = 'de' | 'us';
2222

2323
function getDefaultHosts(region?: Region): Host[] {
24-
const regionHost = region ? `.${region}.` : '.';
24+
const url = !region
25+
? 'insights.algolia.io'
26+
: 'insights.{region}.algolia.io'.replace('{region}', region);
2527

26-
return [
27-
{
28-
url: `insights${regionHost}algolia.io`,
29-
accept: 'readWrite',
30-
protocol: 'https',
31-
},
32-
];
28+
return [{ url, accept: 'readWrite', protocol: 'https' }];
3329
}
3430

3531
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ export const apiClientVersion = '0.2.0';
2323
export type Region = 'eu' | 'us';
2424

2525
function getDefaultHosts(region: Region): Host[] {
26-
return [
27-
{
28-
url: `personalization.${region}.algolia.com`,
29-
accept: 'readWrite',
30-
protocol: 'https',
31-
},
32-
];
26+
const url = 'personalization.{region}.algolia.com'.replace(
27+
'{region}',
28+
region
29+
);
30+
31+
return [{ url, accept: 'readWrite', protocol: 'https' }];
3332
}
3433

3534
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-javascript/packages/client-predict/builds/browser.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import {
77
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';
88

99
import { createPredictClient, apiClientVersion } from '../src/predictClient';
10-
import type { PredictClient } from '../src/predictClient';
10+
import type { PredictClient, Region } from '../src/predictClient';
1111

1212
export * from '../src/predictClient';
1313

1414
export function predictClient(
1515
appId: string,
1616
apiKey: string,
17+
region: Region,
1718
options?: InitClientOptions
1819
): PredictClient {
1920
if (!appId) {
@@ -24,9 +25,14 @@ export function predictClient(
2425
throw new Error('`apiKey` is missing.');
2526
}
2627

28+
if (!region) {
29+
throw new Error('`region` is missing.');
30+
}
31+
2732
return createPredictClient({
2833
appId,
2934
apiKey,
35+
region,
3036
timeouts: {
3137
connect: 1,
3238
read: 2,

clients/algoliasearch-client-javascript/packages/client-predict/builds/node.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import {
66
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';
77

88
import { createPredictClient } from '../src/predictClient';
9-
import type { PredictClient } from '../src/predictClient';
9+
import type { PredictClient, Region } from '../src/predictClient';
1010

1111
export * from '../src/predictClient';
1212

1313
export function predictClient(
1414
appId: string,
1515
apiKey: string,
16+
region: Region,
1617
options?: InitClientOptions
1718
): PredictClient {
1819
if (!appId) {
@@ -23,9 +24,14 @@ export function predictClient(
2324
throw new Error('`apiKey` is missing.');
2425
}
2526

27+
if (!region) {
28+
throw new Error('`region` is missing.');
29+
}
30+
2631
return createPredictClient({
2732
appId,
2833
apiKey,
34+
region,
2935
timeouts: {
3036
connect: 2,
3137
read: 5,

clients/algoliasearch-client-javascript/packages/client-predict/src/predictClient.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,24 @@ import type { Params } from '../model/params';
1818
export * from '../model';
1919
export const apiClientVersion = '0.2.0';
2020

21-
function getDefaultHosts(): Host[] {
22-
return [
23-
{
24-
url: 'predict-api-432xa6wemq-ew.a.run.app',
25-
accept: 'readWrite',
26-
protocol: 'https',
27-
},
28-
];
21+
export type Region = 'ew';
22+
23+
function getDefaultHosts(region: Region): Host[] {
24+
const url = 'predict-api-432xa6wemq-{region}.a.run.app'.replace(
25+
'{region}',
26+
region
27+
);
28+
29+
return [{ url, accept: 'readWrite', protocol: 'https' }];
2930
}
3031

3132
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
32-
export function createPredictClient(options: CreateClientOptions) {
33+
export function createPredictClient(
34+
options: CreateClientOptions & { region: Region }
35+
) {
3336
const auth = createAuth(options.appId, options.apiKey, options.authMode);
3437
const transporter = createTransporter({
35-
hosts: options?.hosts ?? getDefaultHosts(),
38+
hosts: options?.hosts ?? getDefaultHosts(options.region),
3639
hostsCache: options.hostsCache,
3740
requestsCache: options.requestsCache,
3841
responsesCache: options.responsesCache,

clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ export const apiClientVersion = '0.2.0';
2525
export type Region = 'eu' | 'us';
2626

2727
function getDefaultHosts(region: Region): Host[] {
28-
return [
29-
{
30-
url: `query-suggestions.${region}.algolia.com`,
31-
accept: 'readWrite',
32-
protocol: 'https',
33-
},
34-
];
28+
const url = 'query-suggestions.{region}.algolia.com'.replace(
29+
'{region}',
30+
region
31+
);
32+
33+
return [{ url, accept: 'readWrite', protocol: 'https' }];
3534
}
3635

3736
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesClient.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ export const apiClientVersion = '0.2.0';
2121
export type Region = 'de' | 'us';
2222

2323
function getDefaultHosts(region: Region): Host[] {
24-
return [
25-
{
26-
url: `data.${region}.algolia.com`,
27-
accept: 'readWrite',
28-
protocol: 'https',
29-
},
30-
];
24+
const url = 'data.{region}.algolia.com'.replace('{region}', region);
25+
26+
return [{ url, accept: 'readWrite', protocol: 'https' }];
3127
}
3228

3329
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

clients/algoliasearch-client-php/lib/Api/AbtestingClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ public static function createWithConfig(AbtestingConfig $config)
7373
// If a list of hosts was passed, we ignore the cache
7474
$clusterHosts = ClusterHosts::create($hosts);
7575
} else {
76-
$clusterHosts = ClusterHosts::create(
77-
'analytics.' . $config->getRegion() . '.algolia.com'
76+
$url = str_replace(
77+
'{region}',
78+
$config->getRegion(),
79+
'analytics.{region}.algolia.com'
7880
);
81+
$clusterHosts = ClusterHosts::create($url);
7982
}
8083

8184
$apiWrapper = new ApiWrapper(

clients/algoliasearch-client-php/lib/Api/AnalyticsClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ public static function createWithConfig(AnalyticsConfig $config)
7373
// If a list of hosts was passed, we ignore the cache
7474
$clusterHosts = ClusterHosts::create($hosts);
7575
} else {
76-
$clusterHosts = ClusterHosts::create(
77-
'analytics.' . $config->getRegion() . '.algolia.com'
76+
$url = str_replace(
77+
'{region}',
78+
$config->getRegion(),
79+
'analytics.{region}.algolia.com'
7880
);
81+
$clusterHosts = ClusterHosts::create($url);
7982
}
8083

8184
$apiWrapper = new ApiWrapper(

clients/algoliasearch-client-php/lib/Api/InsightsClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,12 @@ public static function createWithConfig(InsightsConfig $config)
7272
// If a list of hosts was passed, we ignore the cache
7373
$clusterHosts = ClusterHosts::create($hosts);
7474
} else {
75-
$clusterHosts = ClusterHosts::create(
76-
'insights.' . $config->getRegion() . '.algolia.io'
75+
$url = str_replace(
76+
'{region}',
77+
$config->getRegion(),
78+
'insights.{region}.algolia.io'
7779
);
80+
$clusterHosts = ClusterHosts::create($url);
7881
}
7982

8083
$apiWrapper = new ApiWrapper(

0 commit comments

Comments
 (0)