Skip to content

Commit 7c26c5e

Browse files
chore: generated code for commit 95ba001. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 95ba001 commit 7c26c5e

File tree

249 files changed

+1928
-516
lines changed

Some content is hidden

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

249 files changed

+1928
-516
lines changed

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,38 +2448,45 @@ public CompletableFuture<Map<String, String>> getObjectAsync(String indexName, S
24482448
* Retrieve one or more objects, potentially from different indices, in a single API call.
24492449
*
24502450
* @param getObjectsParams The Algolia object. (required)
2451+
* @param innerType The class held by the index, could be your custom class or {@link Object}
24512452
* @param requestOptions The requestOptions to send along with the query, they will be merged with
24522453
* the transporter requestOptions.
2453-
* @return GetObjectsResponse
2454+
* @return <T> GetObjectsResponse<T>
24542455
* @throws AlgoliaRuntimeException If it fails to process the API call
24552456
*/
2456-
public GetObjectsResponse getObjects(GetObjectsParams getObjectsParams, RequestOptions requestOptions) throws AlgoliaRuntimeException {
2457-
return LaunderThrowable.await(getObjectsAsync(getObjectsParams, requestOptions));
2457+
public <T> GetObjectsResponse<T> getObjects(GetObjectsParams getObjectsParams, Class<T> innerType, RequestOptions requestOptions)
2458+
throws AlgoliaRuntimeException {
2459+
return LaunderThrowable.await(getObjectsAsync(getObjectsParams, innerType, requestOptions));
24582460
}
24592461

24602462
/**
24612463
* Retrieve one or more objects, potentially from different indices, in a single API call.
24622464
*
24632465
* @param getObjectsParams The Algolia object. (required)
2464-
* @return GetObjectsResponse
2466+
* @param innerType The class held by the index, could be your custom class or {@link Object}
2467+
* @return <T> GetObjectsResponse<T>
24652468
* @throws AlgoliaRuntimeException If it fails to process the API call
24662469
*/
2467-
public GetObjectsResponse getObjects(GetObjectsParams getObjectsParams) throws AlgoliaRuntimeException {
2468-
return this.getObjects(getObjectsParams, null);
2470+
public <T> GetObjectsResponse<T> getObjects(GetObjectsParams getObjectsParams, Class<T> innerType) throws AlgoliaRuntimeException {
2471+
return this.getObjects(getObjectsParams, innerType, null);
24692472
}
24702473

24712474
/**
24722475
* (asynchronously) Retrieve one or more objects, potentially from different indices, in a single
24732476
* API call.
24742477
*
24752478
* @param getObjectsParams The Algolia object. (required)
2479+
* @param innerType The class held by the index, could be your custom class or {@link Object}
24762480
* @param requestOptions The requestOptions to send along with the query, they will be merged with
24772481
* the transporter requestOptions.
2478-
* @return CompletableFuture<GetObjectsResponse> The awaitable future
2482+
* @return <T> CompletableFuture<GetObjectsResponse<T>> The awaitable future
24792483
* @throws AlgoliaRuntimeException If it fails to process the API call
24802484
*/
2481-
public CompletableFuture<GetObjectsResponse> getObjectsAsync(GetObjectsParams getObjectsParams, RequestOptions requestOptions)
2482-
throws AlgoliaRuntimeException {
2485+
public <T> CompletableFuture<GetObjectsResponse<T>> getObjectsAsync(
2486+
GetObjectsParams getObjectsParams,
2487+
Class<T> innerType,
2488+
RequestOptions requestOptions
2489+
) throws AlgoliaRuntimeException {
24832490
if (getObjectsParams == null) {
24842491
throw new AlgoliaRuntimeException("Parameter `getObjectsParams` is required when calling `getObjects`.");
24852492
}
@@ -2493,19 +2500,21 @@ public CompletableFuture<GetObjectsResponse> getObjectsAsync(GetObjectsParams ge
24932500
Map<String, String> headers = new HashMap<String, String>();
24942501

24952502
Call call = this.buildCall(requestPath, "POST", queryParameters, bodyObj, headers, requestOptions, true);
2496-
return this.executeAsync(call, new TypeReference<GetObjectsResponse>() {});
2503+
return this.executeAsync(call, GetObjectsResponse.class, innerType);
24972504
}
24982505

24992506
/**
25002507
* (asynchronously) Retrieve one or more objects, potentially from different indices, in a single
25012508
* API call.
25022509
*
25032510
* @param getObjectsParams The Algolia object. (required)
2504-
* @return CompletableFuture<GetObjectsResponse> The awaitable future
2511+
* @param innerType The class held by the index, could be your custom class or {@link Object}
2512+
* @return <T> CompletableFuture<GetObjectsResponse<T>> The awaitable future
25052513
* @throws AlgoliaRuntimeException If it fails to process the API call
25062514
*/
2507-
public CompletableFuture<GetObjectsResponse> getObjectsAsync(GetObjectsParams getObjectsParams) throws AlgoliaRuntimeException {
2508-
return this.getObjectsAsync(getObjectsParams, null);
2515+
public <T> CompletableFuture<GetObjectsResponse<T>> getObjectsAsync(GetObjectsParams getObjectsParams, Class<T> innerType)
2516+
throws AlgoliaRuntimeException {
2517+
return this.getObjectsAsync(getObjectsParams, innerType, null);
25092518
}
25102519

25112520
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// This file is generated, manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation.
3+
4+
package com.algolia.model.recommend;
5+
6+
import com.algolia.utils.CompoundType;
7+
import com.fasterxml.jackson.annotation.*;
8+
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.type.TypeReference;
10+
import com.fasterxml.jackson.databind.*;
11+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
12+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
13+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
14+
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
15+
import java.io.IOException;
16+
17+
/** Enables de-duplication or grouping of results. */
18+
@JsonDeserialize(using = Distinct.DistinctDeserializer.class)
19+
@JsonSerialize(using = Distinct.DistinctSerializer.class)
20+
public abstract class Distinct implements CompoundType {
21+
22+
public static Distinct of(Boolean inside) {
23+
return new DistinctBoolean(inside);
24+
}
25+
26+
public static Distinct of(Integer inside) {
27+
return new DistinctInteger(inside);
28+
}
29+
30+
public static class DistinctSerializer extends StdSerializer<Distinct> {
31+
32+
public DistinctSerializer(Class<Distinct> t) {
33+
super(t);
34+
}
35+
36+
public DistinctSerializer() {
37+
this(null);
38+
}
39+
40+
@Override
41+
public void serialize(Distinct value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
42+
jgen.writeObject(value.getInsideValue());
43+
}
44+
}
45+
46+
public static class DistinctDeserializer extends StdDeserializer<Distinct> {
47+
48+
public DistinctDeserializer() {
49+
this(Distinct.class);
50+
}
51+
52+
public DistinctDeserializer(Class<?> vc) {
53+
super(vc);
54+
}
55+
56+
@Override
57+
public Distinct deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
58+
JsonNode tree = jp.readValueAsTree();
59+
Distinct deserialized = null;
60+
61+
int match = 0;
62+
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
63+
String currentType = "";
64+
// deserialize Boolean
65+
try {
66+
boolean attemptParsing = true;
67+
currentType = "Boolean";
68+
if (
69+
((currentType.equals("Integer") || currentType.equals("Long")) && token == JsonToken.VALUE_NUMBER_INT) |
70+
((currentType.equals("Float") || currentType.equals("Double")) && token == JsonToken.VALUE_NUMBER_FLOAT) |
71+
(currentType.equals("Boolean") && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)) |
72+
(currentType.equals("String") && token == JsonToken.VALUE_STRING) |
73+
(currentType.startsWith("List<") && token == JsonToken.START_ARRAY)
74+
) {
75+
deserialized = Distinct.of((Boolean) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Boolean>() {}));
76+
match++;
77+
} else if (token == JsonToken.START_OBJECT) {
78+
try {
79+
deserialized = Distinct.of((Boolean) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Boolean>() {}));
80+
match++;
81+
} catch (IOException e) {
82+
// do nothing
83+
}
84+
}
85+
} catch (Exception e) {
86+
// deserialization failed, continue
87+
System.err.println("Failed to deserialize oneOf Boolean (error: " + e.getMessage() + ") (type: " + currentType + ")");
88+
}
89+
90+
// deserialize Integer
91+
try {
92+
boolean attemptParsing = true;
93+
currentType = "Integer";
94+
if (
95+
((currentType.equals("Integer") || currentType.equals("Long")) && token == JsonToken.VALUE_NUMBER_INT) |
96+
((currentType.equals("Float") || currentType.equals("Double")) && token == JsonToken.VALUE_NUMBER_FLOAT) |
97+
(currentType.equals("Boolean") && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)) |
98+
(currentType.equals("String") && token == JsonToken.VALUE_STRING) |
99+
(currentType.startsWith("List<") && token == JsonToken.START_ARRAY)
100+
) {
101+
deserialized = Distinct.of((Integer) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Integer>() {}));
102+
match++;
103+
} else if (token == JsonToken.START_OBJECT) {
104+
try {
105+
deserialized = Distinct.of((Integer) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Integer>() {}));
106+
match++;
107+
} catch (IOException e) {
108+
// do nothing
109+
}
110+
}
111+
} catch (Exception e) {
112+
// deserialization failed, continue
113+
System.err.println("Failed to deserialize oneOf Integer (error: " + e.getMessage() + ") (type: " + currentType + ")");
114+
}
115+
116+
if (match == 1) {
117+
return deserialized;
118+
}
119+
throw new IOException(String.format("Failed deserialization for Distinct: %d classes match result, expected 1", match));
120+
}
121+
122+
/** Handle deserialization of the 'null' value. */
123+
@Override
124+
public Distinct getNullValue(DeserializationContext ctxt) throws JsonMappingException {
125+
throw new JsonMappingException(ctxt.getParser(), "Distinct cannot be null");
126+
}
127+
}
128+
}
129+
130+
class DistinctBoolean extends Distinct {
131+
132+
private final Boolean insideValue;
133+
134+
DistinctBoolean(Boolean insideValue) {
135+
this.insideValue = insideValue;
136+
}
137+
138+
@Override
139+
public Boolean getInsideValue() {
140+
return insideValue;
141+
}
142+
}
143+
144+
class DistinctInteger extends Distinct {
145+
146+
private final Integer insideValue;
147+
148+
DistinctInteger(Integer insideValue) {
149+
this.insideValue = insideValue;
150+
}
151+
152+
@Override
153+
public Integer getInsideValue() {
154+
return insideValue;
155+
}
156+
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/IndexSettingsAsSearchParams.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class IndexSettingsAsSearchParams {
114114
private List<AdvancedSyntaxFeatures> advancedSyntaxFeatures;
115115

116116
@JsonProperty("distinct")
117-
private Integer distinct;
117+
private Distinct distinct;
118118

119119
@JsonProperty("synonyms")
120120
private Boolean synonyms;
@@ -764,18 +764,18 @@ public List<AdvancedSyntaxFeatures> getAdvancedSyntaxFeatures() {
764764
return advancedSyntaxFeatures;
765765
}
766766

767-
public IndexSettingsAsSearchParams setDistinct(Integer distinct) {
767+
public IndexSettingsAsSearchParams setDistinct(Distinct distinct) {
768768
this.distinct = distinct;
769769
return this;
770770
}
771771

772772
/**
773-
* Enables de-duplication or grouping of results. minimum: 0 maximum: 4
773+
* Get distinct
774774
*
775775
* @return distinct
776776
*/
777777
@javax.annotation.Nullable
778-
public Integer getDistinct() {
778+
public Distinct getDistinct() {
779779
return distinct;
780780
}
781781

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/SearchParamsObject.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public class SearchParamsObject {
216216
private List<AdvancedSyntaxFeatures> advancedSyntaxFeatures;
217217

218218
@JsonProperty("distinct")
219-
private Integer distinct;
219+
private Distinct distinct;
220220

221221
@JsonProperty("synonyms")
222222
private Boolean synonyms;
@@ -1430,18 +1430,18 @@ public List<AdvancedSyntaxFeatures> getAdvancedSyntaxFeatures() {
14301430
return advancedSyntaxFeatures;
14311431
}
14321432

1433-
public SearchParamsObject setDistinct(Integer distinct) {
1433+
public SearchParamsObject setDistinct(Distinct distinct) {
14341434
this.distinct = distinct;
14351435
return this;
14361436
}
14371437

14381438
/**
1439-
* Enables de-duplication or grouping of results. minimum: 0 maximum: 4
1439+
* Get distinct
14401440
*
14411441
* @return distinct
14421442
*/
14431443
@javax.annotation.Nullable
1444-
public Integer getDistinct() {
1444+
public Distinct getDistinct() {
14451445
return distinct;
14461446
}
14471447

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BatchParams.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
public class BatchParams {
1313

1414
@JsonProperty("requests")
15-
private List<MultipleBatchOperation> requests;
15+
private List<MultipleBatchRequest> requests;
1616

17-
public BatchParams setRequests(List<MultipleBatchOperation> requests) {
17+
public BatchParams setRequests(List<MultipleBatchRequest> requests) {
1818
this.requests = requests;
1919
return this;
2020
}
2121

22-
public BatchParams addRequests(MultipleBatchOperation requestsItem) {
22+
public BatchParams addRequests(MultipleBatchRequest requestsItem) {
2323
if (this.requests == null) {
2424
this.requests = new ArrayList<>();
2525
}
@@ -33,7 +33,7 @@ public BatchParams addRequests(MultipleBatchOperation requestsItem) {
3333
* @return requests
3434
*/
3535
@javax.annotation.Nullable
36-
public List<MultipleBatchOperation> getRequests() {
36+
public List<MultipleBatchRequest> getRequests() {
3737
return requests;
3838
}
3939

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
import com.fasterxml.jackson.annotation.*;
77
import java.util.Objects;
88

9-
/** BatchOperation */
10-
public class BatchOperation {
9+
/** BatchRequest */
10+
public class BatchRequest {
1111

1212
@JsonProperty("action")
1313
private Action action;
1414

1515
@JsonProperty("body")
1616
private Object body;
1717

18-
public BatchOperation setAction(Action action) {
18+
public BatchRequest setAction(Action action) {
1919
this.action = action;
2020
return this;
2121
}
@@ -30,7 +30,7 @@ public Action getAction() {
3030
return action;
3131
}
3232

33-
public BatchOperation setBody(Object body) {
33+
public BatchRequest setBody(Object body) {
3434
this.body = body;
3535
return this;
3636
}
@@ -53,8 +53,8 @@ public boolean equals(Object o) {
5353
if (o == null || getClass() != o.getClass()) {
5454
return false;
5555
}
56-
BatchOperation batchOperation = (BatchOperation) o;
57-
return Objects.equals(this.action, batchOperation.action) && Objects.equals(this.body, batchOperation.body);
56+
BatchRequest batchRequest = (BatchRequest) o;
57+
return Objects.equals(this.action, batchRequest.action) && Objects.equals(this.body, batchRequest.body);
5858
}
5959

6060
@Override
@@ -65,7 +65,7 @@ public int hashCode() {
6565
@Override
6666
public String toString() {
6767
StringBuilder sb = new StringBuilder();
68-
sb.append("class BatchOperation {\n");
68+
sb.append("class BatchRequest {\n");
6969
sb.append(" action: ").append(toIndentedString(action)).append("\n");
7070
sb.append(" body: ").append(toIndentedString(body)).append("\n");
7171
sb.append("}");

0 commit comments

Comments
 (0)