Skip to content

Commit c72d586

Browse files
algolia-botshortcutsmillotp
committed
chore: generated code for commit da45204. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent da45204 commit c72d586

File tree

7 files changed

+542
-15
lines changed

7 files changed

+542
-15
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class BatchResponse {
1212
private Long taskID;
1313

1414
@SerializedName("objectIDs")
15-
private List<String> objectIDs = null;
15+
private List<String> objectIDs = new ArrayList<>();
1616

1717
public BatchResponse setTaskID(Long taskID) {
1818
this.taskID = taskID;
@@ -24,7 +24,7 @@ public BatchResponse setTaskID(Long taskID) {
2424
*
2525
* @return taskID
2626
*/
27-
@javax.annotation.Nullable
27+
@javax.annotation.Nonnull
2828
public Long getTaskID() {
2929
return taskID;
3030
}
@@ -35,9 +35,6 @@ public BatchResponse setObjectIDs(List<String> objectIDs) {
3535
}
3636

3737
public BatchResponse addObjectIDs(String objectIDsItem) {
38-
if (this.objectIDs == null) {
39-
this.objectIDs = new ArrayList<>();
40-
}
4138
this.objectIDs.add(objectIDsItem);
4239
return this;
4340
}
@@ -47,7 +44,7 @@ public BatchResponse addObjectIDs(String objectIDsItem) {
4744
*
4845
* @return objectIDs
4946
*/
50-
@javax.annotation.Nullable
47+
@javax.annotation.Nonnull
5148
public List<String> getObjectIDs() {
5249
return objectIDs;
5350
}

clients/algoliasearch-client-javascript/packages/client-search/model/batchResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export type BatchResponse = {
22
/**
33
* TaskID of the task to wait for.
44
*/
5-
taskID?: number;
5+
taskID: number;
66
/**
77
* List of objectID.
88
*/
9-
objectIDs?: string[];
9+
objectIDs: string[];
1010
};

clients/algoliasearch-client-php/lib/Model/Search/BatchResponse.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public function listInvalidProperties()
124124
{
125125
$invalidProperties = [];
126126

127+
if (
128+
!isset($this->container['taskID']) ||
129+
$this->container['taskID'] === null
130+
) {
131+
$invalidProperties[] = "'taskID' can't be null";
132+
}
133+
if (
134+
!isset($this->container['objectIDs']) ||
135+
$this->container['objectIDs'] === null
136+
) {
137+
$invalidProperties[] = "'objectIDs' can't be null";
138+
}
139+
127140
return $invalidProperties;
128141
}
129142

@@ -141,7 +154,7 @@ public function valid()
141154
/**
142155
* Gets taskID
143156
*
144-
* @return int|null
157+
* @return int
145158
*/
146159
public function getTaskID()
147160
{
@@ -151,7 +164,7 @@ public function getTaskID()
151164
/**
152165
* Sets taskID
153166
*
154-
* @param int|null $taskID taskID of the task to wait for
167+
* @param int $taskID taskID of the task to wait for
155168
*
156169
* @return self
157170
*/
@@ -165,7 +178,7 @@ public function setTaskID($taskID)
165178
/**
166179
* Gets objectIDs
167180
*
168-
* @return string[]|null
181+
* @return string[]
169182
*/
170183
public function getObjectIDs()
171184
{
@@ -175,7 +188,7 @@ public function getObjectIDs()
175188
/**
176189
* Sets objectIDs
177190
*
178-
* @param string[]|null $objectIDs list of objectID
191+
* @param string[] $objectIDs list of objectID
179192
*
180193
* @return self
181194
*/

specs/bundled/search.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,9 @@ paths:
26532653
$ref: '#/components/schemas/taskID'
26542654
objectIDs:
26552655
$ref: '#/components/schemas/objectIDs'
2656+
required:
2657+
- taskID
2658+
- objectIDs
26562659
'400':
26572660
$ref: '#/components/responses/BadRequest'
26582661
'402':

tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java

Lines changed: 247 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,90 @@ void assignUserIdTest0() {
157157
}
158158

159159
@Test
160-
@DisplayName("batch")
160+
@DisplayName("allows batch method with `addObject` action")
161161
void batchTest0() {
162+
String indexName0 = "theIndexName";
163+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
164+
{
165+
List<BatchOperation> requests1 = new ArrayList<>();
166+
{
167+
BatchOperation requests_02 = new BatchOperation();
168+
{
169+
Action action3 = Action.fromValue("addObject");
170+
requests_02.setAction(action3);
171+
Map<String, String> body3 = new HashMap<>();
172+
{
173+
String key4 = "value";
174+
body3.put("key", key4);
175+
}
176+
requests_02.setBody(body3);
177+
}
178+
requests1.add(requests_02);
179+
}
180+
batchWriteParams0.setRequests(requests1);
181+
}
182+
183+
assertDoesNotThrow(() -> {
184+
client.batch(indexName0, batchWriteParams0);
185+
});
186+
EchoResponse req = echo.getLastResponse();
187+
188+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
189+
assertEquals(req.method, "POST");
190+
191+
assertDoesNotThrow(() -> {
192+
JSONAssert.assertEquals(
193+
"{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"}}]}",
194+
req.body,
195+
JSONCompareMode.STRICT_ORDER
196+
);
197+
});
198+
}
199+
200+
@Test
201+
@DisplayName("allows batch method with `clear` action")
202+
void batchTest1() {
203+
String indexName0 = "theIndexName";
204+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
205+
{
206+
List<BatchOperation> requests1 = new ArrayList<>();
207+
{
208+
BatchOperation requests_02 = new BatchOperation();
209+
{
210+
Action action3 = Action.fromValue("clear");
211+
requests_02.setAction(action3);
212+
Map<String, String> body3 = new HashMap<>();
213+
{
214+
String key4 = "value";
215+
body3.put("key", key4);
216+
}
217+
requests_02.setBody(body3);
218+
}
219+
requests1.add(requests_02);
220+
}
221+
batchWriteParams0.setRequests(requests1);
222+
}
223+
224+
assertDoesNotThrow(() -> {
225+
client.batch(indexName0, batchWriteParams0);
226+
});
227+
EchoResponse req = echo.getLastResponse();
228+
229+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
230+
assertEquals(req.method, "POST");
231+
232+
assertDoesNotThrow(() -> {
233+
JSONAssert.assertEquals(
234+
"{\"requests\":[{\"action\":\"clear\",\"body\":{\"key\":\"value\"}}]}",
235+
req.body,
236+
JSONCompareMode.STRICT_ORDER
237+
);
238+
});
239+
}
240+
241+
@Test
242+
@DisplayName("allows batch method with `delete` action")
243+
void batchTest2() {
162244
String indexName0 = "theIndexName";
163245
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
164246
{
@@ -197,6 +279,170 @@ void batchTest0() {
197279
});
198280
}
199281

282+
@Test
283+
@DisplayName("allows batch method with `deleteObject` action")
284+
void batchTest3() {
285+
String indexName0 = "theIndexName";
286+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
287+
{
288+
List<BatchOperation> requests1 = new ArrayList<>();
289+
{
290+
BatchOperation requests_02 = new BatchOperation();
291+
{
292+
Action action3 = Action.fromValue("deleteObject");
293+
requests_02.setAction(action3);
294+
Map<String, String> body3 = new HashMap<>();
295+
{
296+
String key4 = "value";
297+
body3.put("key", key4);
298+
}
299+
requests_02.setBody(body3);
300+
}
301+
requests1.add(requests_02);
302+
}
303+
batchWriteParams0.setRequests(requests1);
304+
}
305+
306+
assertDoesNotThrow(() -> {
307+
client.batch(indexName0, batchWriteParams0);
308+
});
309+
EchoResponse req = echo.getLastResponse();
310+
311+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
312+
assertEquals(req.method, "POST");
313+
314+
assertDoesNotThrow(() -> {
315+
JSONAssert.assertEquals(
316+
"{\"requests\":[{\"action\":\"deleteObject\",\"body\":{\"key\":\"value\"}}]}",
317+
req.body,
318+
JSONCompareMode.STRICT_ORDER
319+
);
320+
});
321+
}
322+
323+
@Test
324+
@DisplayName("allows batch method with `partialUpdateObject` action")
325+
void batchTest4() {
326+
String indexName0 = "theIndexName";
327+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
328+
{
329+
List<BatchOperation> requests1 = new ArrayList<>();
330+
{
331+
BatchOperation requests_02 = new BatchOperation();
332+
{
333+
Action action3 = Action.fromValue("partialUpdateObject");
334+
requests_02.setAction(action3);
335+
Map<String, String> body3 = new HashMap<>();
336+
{
337+
String key4 = "value";
338+
body3.put("key", key4);
339+
}
340+
requests_02.setBody(body3);
341+
}
342+
requests1.add(requests_02);
343+
}
344+
batchWriteParams0.setRequests(requests1);
345+
}
346+
347+
assertDoesNotThrow(() -> {
348+
client.batch(indexName0, batchWriteParams0);
349+
});
350+
EchoResponse req = echo.getLastResponse();
351+
352+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
353+
assertEquals(req.method, "POST");
354+
355+
assertDoesNotThrow(() -> {
356+
JSONAssert.assertEquals(
357+
"{\"requests\":[{\"action\":\"partialUpdateObject\",\"body\":{\"key\":\"value\"}}]}",
358+
req.body,
359+
JSONCompareMode.STRICT_ORDER
360+
);
361+
});
362+
}
363+
364+
@Test
365+
@DisplayName("allows batch method with `partialUpdateObjectNoCreate` action")
366+
void batchTest5() {
367+
String indexName0 = "theIndexName";
368+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
369+
{
370+
List<BatchOperation> requests1 = new ArrayList<>();
371+
{
372+
BatchOperation requests_02 = new BatchOperation();
373+
{
374+
Action action3 = Action.fromValue("partialUpdateObjectNoCreate");
375+
requests_02.setAction(action3);
376+
Map<String, String> body3 = new HashMap<>();
377+
{
378+
String key4 = "value";
379+
body3.put("key", key4);
380+
}
381+
requests_02.setBody(body3);
382+
}
383+
requests1.add(requests_02);
384+
}
385+
batchWriteParams0.setRequests(requests1);
386+
}
387+
388+
assertDoesNotThrow(() -> {
389+
client.batch(indexName0, batchWriteParams0);
390+
});
391+
EchoResponse req = echo.getLastResponse();
392+
393+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
394+
assertEquals(req.method, "POST");
395+
396+
assertDoesNotThrow(() -> {
397+
JSONAssert.assertEquals(
398+
"{\"requests\":[{\"action\":\"partialUpdateObjectNoCreate\",\"body\":{\"key\":\"value\"}}]}",
399+
req.body,
400+
JSONCompareMode.STRICT_ORDER
401+
);
402+
});
403+
}
404+
405+
@Test
406+
@DisplayName("allows batch method with `updateObject` action")
407+
void batchTest6() {
408+
String indexName0 = "theIndexName";
409+
BatchWriteParams batchWriteParams0 = new BatchWriteParams();
410+
{
411+
List<BatchOperation> requests1 = new ArrayList<>();
412+
{
413+
BatchOperation requests_02 = new BatchOperation();
414+
{
415+
Action action3 = Action.fromValue("updateObject");
416+
requests_02.setAction(action3);
417+
Map<String, String> body3 = new HashMap<>();
418+
{
419+
String key4 = "value";
420+
body3.put("key", key4);
421+
}
422+
requests_02.setBody(body3);
423+
}
424+
requests1.add(requests_02);
425+
}
426+
batchWriteParams0.setRequests(requests1);
427+
}
428+
429+
assertDoesNotThrow(() -> {
430+
client.batch(indexName0, batchWriteParams0);
431+
});
432+
EchoResponse req = echo.getLastResponse();
433+
434+
assertEquals(req.path, "/1/indexes/theIndexName/batch");
435+
assertEquals(req.method, "POST");
436+
437+
assertDoesNotThrow(() -> {
438+
JSONAssert.assertEquals(
439+
"{\"requests\":[{\"action\":\"updateObject\",\"body\":{\"key\":\"value\"}}]}",
440+
req.body,
441+
JSONCompareMode.STRICT_ORDER
442+
);
443+
});
444+
}
445+
200446
@Test
201447
@DisplayName("batchAssignUserIds")
202448
void batchAssignUserIdsTest0() {

0 commit comments

Comments
 (0)