Skip to content

Commit 32d094b

Browse files
chore: generated code for commit c2a054f. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c2a054f commit 32d094b

File tree

28 files changed

+7708
-436
lines changed

28 files changed

+7708
-436
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,16 @@ public CompletableFuture<UpdatedAtResponse> batchDictionaryEntriesAsync(
615615
* index has been reached, the cursor field is absent from the response.
616616
*
617617
* @param indexName The index in which to perform the request. (required)
618-
* @param browseRequest (optional)
618+
* @param browseParams (optional)
619619
* @param innerType The class held by the index, could be your custom class or {@link Object}
620620
* @param requestOptions The requestOptions to send along with the query, they will be merged with
621621
* the transporter requestOptions.
622622
* @return <T> BrowseResponse<T>
623623
* @throws AlgoliaRuntimeException If it fails to process the API call
624624
*/
625-
public <T> BrowseResponse<T> browse(String indexName, BrowseRequest browseRequest, Class<T> innerType, RequestOptions requestOptions)
625+
public <T> BrowseResponse<T> browse(String indexName, BrowseParams browseParams, Class<T> innerType, RequestOptions requestOptions)
626626
throws AlgoliaRuntimeException {
627-
return LaunderThrowable.await(browseAsync(indexName, browseRequest, innerType, requestOptions));
627+
return LaunderThrowable.await(browseAsync(indexName, browseParams, innerType, requestOptions));
628628
}
629629

630630
/**
@@ -636,13 +636,13 @@ public <T> BrowseResponse<T> browse(String indexName, BrowseRequest browseReques
636636
* index has been reached, the cursor field is absent from the response.
637637
*
638638
* @param indexName The index in which to perform the request. (required)
639-
* @param browseRequest (optional)
639+
* @param browseParams (optional)
640640
* @param innerType The class held by the index, could be your custom class or {@link Object}
641641
* @return <T> BrowseResponse<T>
642642
* @throws AlgoliaRuntimeException If it fails to process the API call
643643
*/
644-
public <T> BrowseResponse<T> browse(String indexName, BrowseRequest browseRequest, Class<T> innerType) throws AlgoliaRuntimeException {
645-
return this.browse(indexName, browseRequest, innerType, null);
644+
public <T> BrowseResponse<T> browse(String indexName, BrowseParams browseParams, Class<T> innerType) throws AlgoliaRuntimeException {
645+
return this.browse(indexName, browseParams, innerType, null);
646646
}
647647

648648
/**
@@ -691,7 +691,7 @@ public <T> BrowseResponse<T> browse(String indexName, Class<T> innerType) throws
691691
* cursor field is absent from the response.
692692
*
693693
* @param indexName The index in which to perform the request. (required)
694-
* @param browseRequest (optional)
694+
* @param browseParams (optional)
695695
* @param innerType The class held by the index, could be your custom class or {@link Object}
696696
* @param requestOptions The requestOptions to send along with the query, they will be merged with
697697
* the transporter requestOptions.
@@ -700,15 +700,15 @@ public <T> BrowseResponse<T> browse(String indexName, Class<T> innerType) throws
700700
*/
701701
public <T> CompletableFuture<BrowseResponse<T>> browseAsync(
702702
String indexName,
703-
BrowseRequest browseRequest,
703+
BrowseParams browseParams,
704704
Class<T> innerType,
705705
RequestOptions requestOptions
706706
) throws AlgoliaRuntimeException {
707707
if (indexName == null) {
708708
throw new AlgoliaRuntimeException("Parameter `indexName` is required when calling `browse`.");
709709
}
710710

711-
Object bodyObj = browseRequest != null ? browseRequest : new Object();
711+
Object bodyObj = browseParams != null ? browseParams : new Object();
712712

713713
// create path and map variables
714714
String requestPath = "/1/indexes/{indexName}/browse".replaceAll("\\{indexName\\}", this.escapeString(indexName.toString()));
@@ -730,14 +730,14 @@ public <T> CompletableFuture<BrowseResponse<T>> browseAsync(
730730
* cursor field is absent from the response.
731731
*
732732
* @param indexName The index in which to perform the request. (required)
733-
* @param browseRequest (optional)
733+
* @param browseParams (optional)
734734
* @param innerType The class held by the index, could be your custom class or {@link Object}
735735
* @return <T> CompletableFuture<BrowseResponse<T>> The awaitable future
736736
* @throws AlgoliaRuntimeException If it fails to process the API call
737737
*/
738-
public <T> CompletableFuture<BrowseResponse<T>> browseAsync(String indexName, BrowseRequest browseRequest, Class<T> innerType)
738+
public <T> CompletableFuture<BrowseResponse<T>> browseAsync(String indexName, BrowseParams browseParams, Class<T> innerType)
739739
throws AlgoliaRuntimeException {
740-
return this.browseAsync(indexName, browseRequest, innerType, null);
740+
return this.browseAsync(indexName, browseParams, innerType, null);
741741
}
742742

743743
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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.search;
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+
/** BrowseParams */
18+
@JsonDeserialize(using = BrowseParams.BrowseParamsDeserializer.class)
19+
@JsonSerialize(using = BrowseParams.BrowseParamsSerializer.class)
20+
public abstract class BrowseParams implements CompoundType {
21+
22+
public static BrowseParams of(BrowseParamsObject inside) {
23+
return new BrowseParamsBrowseParamsObject(inside);
24+
}
25+
26+
public static BrowseParams of(SearchParamsString inside) {
27+
return new BrowseParamsSearchParamsString(inside);
28+
}
29+
30+
public static class BrowseParamsSerializer extends StdSerializer<BrowseParams> {
31+
32+
public BrowseParamsSerializer(Class<BrowseParams> t) {
33+
super(t);
34+
}
35+
36+
public BrowseParamsSerializer() {
37+
this(null);
38+
}
39+
40+
@Override
41+
public void serialize(BrowseParams value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
42+
jgen.writeObject(value.getInsideValue());
43+
}
44+
}
45+
46+
public static class BrowseParamsDeserializer extends StdDeserializer<BrowseParams> {
47+
48+
public BrowseParamsDeserializer() {
49+
this(BrowseParams.class);
50+
}
51+
52+
public BrowseParamsDeserializer(Class<?> vc) {
53+
super(vc);
54+
}
55+
56+
@Override
57+
public BrowseParams deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
58+
JsonNode tree = jp.readValueAsTree();
59+
BrowseParams deserialized = null;
60+
61+
int match = 0;
62+
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
63+
String currentType = "";
64+
// deserialize BrowseParamsObject
65+
try {
66+
boolean attemptParsing = true;
67+
currentType = "BrowseParamsObject";
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 =
76+
BrowseParams.of((BrowseParamsObject) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<BrowseParamsObject>() {}));
77+
match++;
78+
} else if (token == JsonToken.START_OBJECT) {
79+
try {
80+
deserialized =
81+
BrowseParams.of((BrowseParamsObject) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<BrowseParamsObject>() {}));
82+
match++;
83+
} catch (IOException e) {
84+
// do nothing
85+
}
86+
}
87+
} catch (Exception e) {
88+
// deserialization failed, continue
89+
System.err.println("Failed to deserialize oneOf BrowseParamsObject (error: " + e.getMessage() + ") (type: " + currentType + ")");
90+
}
91+
92+
// deserialize SearchParamsString
93+
try {
94+
boolean attemptParsing = true;
95+
currentType = "SearchParamsString";
96+
if (
97+
((currentType.equals("Integer") || currentType.equals("Long")) && token == JsonToken.VALUE_NUMBER_INT) |
98+
((currentType.equals("Float") || currentType.equals("Double")) && token == JsonToken.VALUE_NUMBER_FLOAT) |
99+
(currentType.equals("Boolean") && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)) |
100+
(currentType.equals("String") && token == JsonToken.VALUE_STRING) |
101+
(currentType.startsWith("List<") && token == JsonToken.START_ARRAY)
102+
) {
103+
deserialized =
104+
BrowseParams.of((SearchParamsString) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<SearchParamsString>() {}));
105+
match++;
106+
} else if (token == JsonToken.START_OBJECT) {
107+
try {
108+
deserialized =
109+
BrowseParams.of((SearchParamsString) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<SearchParamsString>() {}));
110+
match++;
111+
} catch (IOException e) {
112+
// do nothing
113+
}
114+
}
115+
} catch (Exception e) {
116+
// deserialization failed, continue
117+
System.err.println("Failed to deserialize oneOf SearchParamsString (error: " + e.getMessage() + ") (type: " + currentType + ")");
118+
}
119+
120+
if (match == 1) {
121+
return deserialized;
122+
}
123+
throw new IOException(String.format("Failed deserialization for BrowseParams: %d classes match result, expected 1", match));
124+
}
125+
126+
/** Handle deserialization of the 'null' value. */
127+
@Override
128+
public BrowseParams getNullValue(DeserializationContext ctxt) throws JsonMappingException {
129+
throw new JsonMappingException(ctxt.getParser(), "BrowseParams cannot be null");
130+
}
131+
}
132+
}
133+
134+
class BrowseParamsBrowseParamsObject extends BrowseParams {
135+
136+
private final BrowseParamsObject insideValue;
137+
138+
BrowseParamsBrowseParamsObject(BrowseParamsObject insideValue) {
139+
this.insideValue = insideValue;
140+
}
141+
142+
@Override
143+
public BrowseParamsObject getInsideValue() {
144+
return insideValue;
145+
}
146+
}
147+
148+
class BrowseParamsSearchParamsString extends BrowseParams {
149+
150+
private final SearchParamsString insideValue;
151+
152+
BrowseParamsSearchParamsString(SearchParamsString insideValue) {
153+
this.insideValue = insideValue;
154+
}
155+
156+
@Override
157+
public SearchParamsString getInsideValue() {
158+
return insideValue;
159+
}
160+
}

0 commit comments

Comments
 (0)