Skip to content

Commit 0e207a4

Browse files
algolia-botmillotp
andcommitted
chore: generated code for commit ad27abc. [skip ci]
Co-authored-by: Pierre Millot <[email protected]>
1 parent ad27abc commit 0e207a4

File tree

31 files changed

+532
-33
lines changed

31 files changed

+532
-33
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import {
99
} from '@experimental-api-clients-automation/client-common';
1010
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';
1111

12+
import type { AbtestingClient, Region } from '../src/abtestingClient';
1213
import {
1314
createAbtestingClient,
1415
apiClientVersion,
16+
REGIONS,
1517
} from '../src/abtestingClient';
16-
import type { AbtestingClient, Region } from '../src/abtestingClient';
1718

1819
export { apiClientVersion, AbtestingClient } from '../src/abtestingClient';
1920
export * from '../model';
@@ -32,6 +33,12 @@ export function abtestingClient(
3233
throw new Error('`apiKey` is missing.');
3334
}
3435

36+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
37+
throw new Error(
38+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
39+
);
40+
}
41+
3542
return createAbtestingClient({
3643
appId,
3744
apiKey,

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

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

1111
import type { AbtestingClient, Region } from '../src/abtestingClient';
12-
import { createAbtestingClient } from '../src/abtestingClient';
12+
import { createAbtestingClient, REGIONS } from '../src/abtestingClient';
1313

1414
export { apiClientVersion, AbtestingClient } from '../src/abtestingClient';
1515
export * from '../model';
@@ -28,6 +28,12 @@ export function abtestingClient(
2828
throw new Error('`apiKey` is missing.');
2929
}
3030

31+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
32+
throw new Error(
33+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
34+
);
35+
}
36+
3137
return createAbtestingClient({
3238
appId,
3339
apiKey,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import {
99
} from '@experimental-api-clients-automation/client-common';
1010
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';
1111

12+
import type { AnalyticsClient, Region } from '../src/analyticsClient';
1213
import {
1314
createAnalyticsClient,
1415
apiClientVersion,
16+
REGIONS,
1517
} from '../src/analyticsClient';
16-
import type { AnalyticsClient, Region } from '../src/analyticsClient';
1718

1819
export { apiClientVersion, AnalyticsClient } from '../src/analyticsClient';
1920
export * from '../model';
@@ -32,6 +33,12 @@ export function analyticsClient(
3233
throw new Error('`apiKey` is missing.');
3334
}
3435

36+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
37+
throw new Error(
38+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
39+
);
40+
}
41+
3542
return createAnalyticsClient({
3643
appId,
3744
apiKey,

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

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

1111
import type { AnalyticsClient, Region } from '../src/analyticsClient';
12-
import { createAnalyticsClient } from '../src/analyticsClient';
12+
import { createAnalyticsClient, REGIONS } from '../src/analyticsClient';
1313

1414
export { apiClientVersion, AnalyticsClient } from '../src/analyticsClient';
1515
export * from '../model';
@@ -28,6 +28,12 @@ export function analyticsClient(
2828
throw new Error('`apiKey` is missing.');
2929
}
3030

31+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
32+
throw new Error(
33+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
34+
);
35+
}
36+
3137
return createAnalyticsClient({
3238
appId,
3339
apiKey,

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

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

1212
import type { InsightsClient, Region } from '../src/insightsClient';
13-
import { createInsightsClient, apiClientVersion } from '../src/insightsClient';
13+
import {
14+
createInsightsClient,
15+
apiClientVersion,
16+
REGIONS,
17+
} from '../src/insightsClient';
1418

1519
export { apiClientVersion, InsightsClient } from '../src/insightsClient';
1620
export * from '../model';
@@ -29,6 +33,12 @@ export function insightsClient(
2933
throw new Error('`apiKey` is missing.');
3034
}
3135

36+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
37+
throw new Error(
38+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
39+
);
40+
}
41+
3242
return createInsightsClient({
3343
appId,
3444
apiKey,

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

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

1111
import type { InsightsClient, Region } from '../src/insightsClient';
12-
import { createInsightsClient } from '../src/insightsClient';
12+
import { createInsightsClient, REGIONS } from '../src/insightsClient';
1313

1414
export { apiClientVersion, InsightsClient } from '../src/insightsClient';
1515
export * from '../model';
@@ -28,6 +28,12 @@ export function insightsClient(
2828
throw new Error('`apiKey` is missing.');
2929
}
3030

31+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
32+
throw new Error(
33+
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
34+
);
35+
}
36+
3137
return createInsightsClient({
3238
appId,
3339
apiKey,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function personalizationClient(
4343
throw new Error('`region` is missing.');
4444
}
4545

46-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
46+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4747
throw new Error(
4848
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4949
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function personalizationClient(
4141
throw new Error('`region` is missing.');
4242
}
4343

44-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
44+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4545
throw new Error(
4646
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4747
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function predictClient(
3737
throw new Error('`region` is missing.');
3838
}
3939

40-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
40+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4141
throw new Error(
4242
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4343
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function predictClient(
3232
throw new Error('`region` is missing.');
3333
}
3434

35-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
35+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
3636
throw new Error(
3737
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
3838
);

clients/algoliasearch-client-javascript/packages/client-query-suggestions/builds/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function querySuggestionsClient(
4343
throw new Error('`region` is missing.');
4444
}
4545

46-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
46+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4747
throw new Error(
4848
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4949
);

clients/algoliasearch-client-javascript/packages/client-query-suggestions/builds/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function querySuggestionsClient(
4141
throw new Error('`region` is missing.');
4242
}
4343

44-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
44+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4545
throw new Error(
4646
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4747
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function sourcesClient(
3737
throw new Error('`region` is missing.');
3838
}
3939

40-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
40+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
4141
throw new Error(
4242
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
4343
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function sourcesClient(
3232
throw new Error('`region` is missing.');
3333
}
3434

35-
if (typeof region !== 'string' || !REGIONS.includes(region)) {
35+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
3636
throw new Error(
3737
`\`region\` must be one of the following: ${REGIONS.join(', ')}`
3838
);

tests/output/java/src/test/java/com/algolia/client/abtesting.test.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.algolia.client;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertThrows;
45
import static org.junit.jupiter.api.Assertions.assertTrue;
56

67
import com.algolia.EchoInterceptor;
@@ -56,12 +57,26 @@ void commonApiTest0() {
5657
}
5758

5859
@Test
59-
@DisplayName("calls api with correct timeouts")
60+
@DisplayName("calls api with default read timeouts")
6061
void commonApiTest1() {
6162
AbtestingClient $client = createClient();
6263

6364
String path0 = "/test";
6465

66+
$client.get(path0);
67+
EchoResponse result = echo.getLastResponse();
68+
69+
assertEquals(2000, result.connectTimeout);
70+
assertEquals(5000, result.responseTimeout);
71+
}
72+
73+
@Test
74+
@DisplayName("calls api with default write timeouts")
75+
void commonApiTest2() {
76+
AbtestingClient $client = createClient();
77+
78+
String path0 = "/test";
79+
6580
$client.post(path0);
6681
EchoResponse result = echo.getLastResponse();
6782

@@ -81,4 +96,36 @@ void parametersTest0() {
8196

8297
assertEquals("analytics.algolia.com", result.host);
8398
}
99+
100+
@Test
101+
@DisplayName("uses the correct region")
102+
void parametersTest1() {
103+
AbtestingClient $client = new AbtestingClient("my-app-id", "my-api-key", "us", ClientOptions.build().setRequester(requester));
104+
105+
int id0 = 123;
106+
107+
$client.getABTest(id0);
108+
EchoResponse result = echo.getLastResponse();
109+
110+
assertEquals("analytics.us.algolia.com", result.host);
111+
}
112+
113+
@Test
114+
@DisplayName("throws when incorrect region is given")
115+
void parametersTest2() {
116+
{
117+
Exception exception = assertThrows(
118+
Exception.class,
119+
() -> {
120+
AbtestingClient $client = new AbtestingClient(
121+
"my-app-id",
122+
"my-api-key",
123+
"not_a_region",
124+
ClientOptions.build().setRequester(requester)
125+
);
126+
}
127+
);
128+
assertEquals("`region` must be one of the following: de, us", exception.getMessage());
129+
}
130+
}
84131
}

tests/output/java/src/test/java/com/algolia/client/analytics.test.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,26 @@ void commonApiTest0() {
5757
}
5858

5959
@Test
60-
@DisplayName("calls api with correct timeouts")
60+
@DisplayName("calls api with default read timeouts")
6161
void commonApiTest1() {
6262
AnalyticsClient $client = createClient();
6363

6464
String path0 = "/test";
6565

66+
$client.get(path0);
67+
EchoResponse result = echo.getLastResponse();
68+
69+
assertEquals(2000, result.connectTimeout);
70+
assertEquals(5000, result.responseTimeout);
71+
}
72+
73+
@Test
74+
@DisplayName("calls api with default write timeouts")
75+
void commonApiTest2() {
76+
AnalyticsClient $client = createClient();
77+
78+
String path0 = "/test";
79+
6680
$client.post(path0);
6781
EchoResponse result = echo.getLastResponse();
6882

@@ -84,8 +98,40 @@ void parametersTest0() {
8498
}
8599

86100
@Test
87-
@DisplayName("getAverageClickPosition throws without index")
101+
@DisplayName("uses the correct region")
88102
void parametersTest1() {
103+
AnalyticsClient $client = new AnalyticsClient("my-app-id", "my-api-key", "de", ClientOptions.build().setRequester(requester));
104+
105+
String path0 = "/test";
106+
107+
$client.post(path0);
108+
EchoResponse result = echo.getLastResponse();
109+
110+
assertEquals("analytics.de.algolia.com", result.host);
111+
}
112+
113+
@Test
114+
@DisplayName("throws when incorrect region is given")
115+
void parametersTest2() {
116+
{
117+
Exception exception = assertThrows(
118+
Exception.class,
119+
() -> {
120+
AnalyticsClient $client = new AnalyticsClient(
121+
"my-app-id",
122+
"my-api-key",
123+
"not_a_region",
124+
ClientOptions.build().setRequester(requester)
125+
);
126+
}
127+
);
128+
assertEquals("`region` must be one of the following: de, us", exception.getMessage());
129+
}
130+
}
131+
132+
@Test
133+
@DisplayName("getAverageClickPosition throws without index")
134+
void parametersTest3() {
89135
AnalyticsClient $client = createClient();
90136

91137
{

0 commit comments

Comments
 (0)