Skip to content

Commit 26b588d

Browse files
algolia-botraed667millotpshortcuts
committed
feat(specs): add recommend batch rules endpoint (generated)
algolia/api-clients-automation#3782 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Raed <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c6d110a commit 26b588d

File tree

4 files changed

+421
-2
lines changed

4 files changed

+421
-2
lines changed

algoliasearch/src/main/java/com/algolia/api/RecommendClient.java

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,239 @@ private static List<Host> getDefaultHosts(String appId) {
4646
return Stream.concat(hosts.stream(), commonHosts.stream()).collect(Collectors.toList());
4747
}
4848

49+
/**
50+
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
51+
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
52+
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
53+
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
54+
* conditions and consequences apply to a [source
55+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
56+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
57+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
58+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
59+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
60+
* match the data source item's attributes instead).
61+
*
62+
* @param indexName Name of the index on which to perform the operation. (required)
63+
* @param model [Recommend
64+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
65+
* (required)
66+
* @param recommendRule (optional)
67+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
68+
* the transporter requestOptions.
69+
* @throws AlgoliaRuntimeException If it fails to process the API call
70+
*/
71+
public RecommendUpdatedAtResponse batchRecommendRules(
72+
@Nonnull String indexName,
73+
@Nonnull RecommendModels model,
74+
List<RecommendRule> recommendRule,
75+
RequestOptions requestOptions
76+
) throws AlgoliaRuntimeException {
77+
return LaunderThrowable.await(batchRecommendRulesAsync(indexName, model, recommendRule, requestOptions));
78+
}
79+
80+
/**
81+
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
82+
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
83+
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
84+
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
85+
* conditions and consequences apply to a [source
86+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
87+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
88+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
89+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
90+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
91+
* match the data source item's attributes instead).
92+
*
93+
* @param indexName Name of the index on which to perform the operation. (required)
94+
* @param model [Recommend
95+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
96+
* (required)
97+
* @param recommendRule (optional)
98+
* @throws AlgoliaRuntimeException If it fails to process the API call
99+
*/
100+
public RecommendUpdatedAtResponse batchRecommendRules(
101+
@Nonnull String indexName,
102+
@Nonnull RecommendModels model,
103+
List<RecommendRule> recommendRule
104+
) throws AlgoliaRuntimeException {
105+
return this.batchRecommendRules(indexName, model, recommendRule, null);
106+
}
107+
108+
/**
109+
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
110+
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
111+
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
112+
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
113+
* conditions and consequences apply to a [source
114+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
115+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
116+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
117+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
118+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
119+
* match the data source item's attributes instead).
120+
*
121+
* @param indexName Name of the index on which to perform the operation. (required)
122+
* @param model [Recommend
123+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
124+
* (required)
125+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
126+
* the transporter requestOptions.
127+
* @throws AlgoliaRuntimeException If it fails to process the API call
128+
*/
129+
public RecommendUpdatedAtResponse batchRecommendRules(
130+
@Nonnull String indexName,
131+
@Nonnull RecommendModels model,
132+
RequestOptions requestOptions
133+
) throws AlgoliaRuntimeException {
134+
return this.batchRecommendRules(indexName, model, null, requestOptions);
135+
}
136+
137+
/**
138+
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
139+
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
140+
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
141+
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
142+
* conditions and consequences apply to a [source
143+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
144+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
145+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
146+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
147+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
148+
* match the data source item's attributes instead).
149+
*
150+
* @param indexName Name of the index on which to perform the operation. (required)
151+
* @param model [Recommend
152+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
153+
* (required)
154+
* @throws AlgoliaRuntimeException If it fails to process the API call
155+
*/
156+
public RecommendUpdatedAtResponse batchRecommendRules(@Nonnull String indexName, @Nonnull RecommendModels model)
157+
throws AlgoliaRuntimeException {
158+
return this.batchRecommendRules(indexName, model, null, null);
159+
}
160+
161+
/**
162+
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
163+
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
164+
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
165+
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
166+
* conditions and consequences apply to a [source
167+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
168+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
169+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
170+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
171+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
172+
* match the data source item's attributes instead).
173+
*
174+
* @param indexName Name of the index on which to perform the operation. (required)
175+
* @param model [Recommend
176+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
177+
* (required)
178+
* @param recommendRule (optional)
179+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
180+
* the transporter requestOptions.
181+
* @throws AlgoliaRuntimeException If it fails to process the API call
182+
*/
183+
public CompletableFuture<RecommendUpdatedAtResponse> batchRecommendRulesAsync(
184+
@Nonnull String indexName,
185+
@Nonnull RecommendModels model,
186+
List<RecommendRule> recommendRule,
187+
RequestOptions requestOptions
188+
) throws AlgoliaRuntimeException {
189+
Parameters.requireNonNull(indexName, "Parameter `indexName` is required when calling `batchRecommendRules`.");
190+
191+
Parameters.requireNonNull(model, "Parameter `model` is required when calling `batchRecommendRules`.");
192+
193+
HttpRequest request = HttpRequest.builder()
194+
.setPath("/1/indexes/{indexName}/{model}/recommend/rules/batch", indexName, model)
195+
.setMethod("POST")
196+
.setBody(recommendRule)
197+
.build();
198+
return executeAsync(request, requestOptions, new TypeReference<RecommendUpdatedAtResponse>() {});
199+
}
200+
201+
/**
202+
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
203+
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
204+
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
205+
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
206+
* conditions and consequences apply to a [source
207+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
208+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
209+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
210+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
211+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
212+
* match the data source item's attributes instead).
213+
*
214+
* @param indexName Name of the index on which to perform the operation. (required)
215+
* @param model [Recommend
216+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
217+
* (required)
218+
* @param recommendRule (optional)
219+
* @throws AlgoliaRuntimeException If it fails to process the API call
220+
*/
221+
public CompletableFuture<RecommendUpdatedAtResponse> batchRecommendRulesAsync(
222+
@Nonnull String indexName,
223+
@Nonnull RecommendModels model,
224+
List<RecommendRule> recommendRule
225+
) throws AlgoliaRuntimeException {
226+
return this.batchRecommendRulesAsync(indexName, model, recommendRule, null);
227+
}
228+
229+
/**
230+
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
231+
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
232+
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
233+
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
234+
* conditions and consequences apply to a [source
235+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
236+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
237+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
238+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
239+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
240+
* match the data source item's attributes instead).
241+
*
242+
* @param indexName Name of the index on which to perform the operation. (required)
243+
* @param model [Recommend
244+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
245+
* (required)
246+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
247+
* the transporter requestOptions.
248+
* @throws AlgoliaRuntimeException If it fails to process the API call
249+
*/
250+
public CompletableFuture<RecommendUpdatedAtResponse> batchRecommendRulesAsync(
251+
@Nonnull String indexName,
252+
@Nonnull RecommendModels model,
253+
RequestOptions requestOptions
254+
) throws AlgoliaRuntimeException {
255+
return this.batchRecommendRulesAsync(indexName, model, null, requestOptions);
256+
}
257+
258+
/**
259+
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
260+
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
261+
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
262+
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
263+
* conditions and consequences apply to a [source
264+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
265+
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
266+
* Condition `filters` triggers if the source item matches the specified filters. - Condition
267+
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
268+
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
269+
* match the data source item's attributes instead).
270+
*
271+
* @param indexName Name of the index on which to perform the operation. (required)
272+
* @param model [Recommend
273+
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
274+
* (required)
275+
* @throws AlgoliaRuntimeException If it fails to process the API call
276+
*/
277+
public CompletableFuture<RecommendUpdatedAtResponse> batchRecommendRulesAsync(@Nonnull String indexName, @Nonnull RecommendModels model)
278+
throws AlgoliaRuntimeException {
279+
return this.batchRecommendRulesAsync(indexName, model, null, null);
280+
}
281+
49282
/**
50283
* This method allow you to send requests to the Algolia REST API.
51284
*

algoliasearch/src/main/java/com/algolia/model/recommend/RecommendRule.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import com.fasterxml.jackson.annotation.*;
77
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.ArrayList;
9+
import java.util.List;
810
import java.util.Objects;
911

1012
/** Recommend rule. */
@@ -28,6 +30,9 @@ public class RecommendRule {
2830
@JsonProperty("enabled")
2931
private Boolean enabled;
3032

33+
@JsonProperty("validity")
34+
private List<TimeRange> validity;
35+
3136
public RecommendRule setMetadata(RuleMetadata metadata) {
3237
this.metadata = metadata;
3338
return this;
@@ -96,6 +101,25 @@ public Boolean getEnabled() {
96101
return enabled;
97102
}
98103

104+
public RecommendRule setValidity(List<TimeRange> validity) {
105+
this.validity = validity;
106+
return this;
107+
}
108+
109+
public RecommendRule addValidity(TimeRange validityItem) {
110+
if (this.validity == null) {
111+
this.validity = new ArrayList<>();
112+
}
113+
this.validity.add(validityItem);
114+
return this;
115+
}
116+
117+
/** Time periods when the rule is active. */
118+
@javax.annotation.Nullable
119+
public List<TimeRange> getValidity() {
120+
return validity;
121+
}
122+
99123
@Override
100124
public boolean equals(Object o) {
101125
if (this == o) {
@@ -111,13 +135,14 @@ public boolean equals(Object o) {
111135
Objects.equals(this.condition, recommendRule.condition) &&
112136
Objects.equals(this.consequence, recommendRule.consequence) &&
113137
Objects.equals(this.description, recommendRule.description) &&
114-
Objects.equals(this.enabled, recommendRule.enabled)
138+
Objects.equals(this.enabled, recommendRule.enabled) &&
139+
Objects.equals(this.validity, recommendRule.validity)
115140
);
116141
}
117142

118143
@Override
119144
public int hashCode() {
120-
return Objects.hash(metadata, objectID, condition, consequence, description, enabled);
145+
return Objects.hash(metadata, objectID, condition, consequence, description, enabled, validity);
121146
}
122147

123148
@Override
@@ -130,6 +155,7 @@ public String toString() {
130155
sb.append(" consequence: ").append(toIndentedString(consequence)).append("\n");
131156
sb.append(" description: ").append(toIndentedString(description)).append("\n");
132157
sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n");
158+
sb.append(" validity: ").append(toIndentedString(validity)).append("\n");
133159
sb.append("}");
134160
return sb.toString();
135161
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.recommend;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import com.fasterxml.jackson.databind.annotation.*;
8+
import java.util.Objects;
9+
10+
/** Response, taskID, and update timestamp. */
11+
public class RecommendUpdatedAtResponse {
12+
13+
@JsonProperty("taskID")
14+
private Long taskID;
15+
16+
@JsonProperty("updatedAt")
17+
private String updatedAt;
18+
19+
public RecommendUpdatedAtResponse setTaskID(Long taskID) {
20+
this.taskID = taskID;
21+
return this;
22+
}
23+
24+
/**
25+
* Unique identifier of a task. A successful API response means that a task was added to a queue.
26+
* It might not run immediately. You can check the task's progress with the [`task`
27+
* operation](#tag/Indices/operation/getTask) and this `taskID`.
28+
*/
29+
@javax.annotation.Nonnull
30+
public Long getTaskID() {
31+
return taskID;
32+
}
33+
34+
public RecommendUpdatedAtResponse setUpdatedAt(String updatedAt) {
35+
this.updatedAt = updatedAt;
36+
return this;
37+
}
38+
39+
/** Date and time when the object was updated, in RFC 3339 format. */
40+
@javax.annotation.Nonnull
41+
public String getUpdatedAt() {
42+
return updatedAt;
43+
}
44+
45+
@Override
46+
public boolean equals(Object o) {
47+
if (this == o) {
48+
return true;
49+
}
50+
if (o == null || getClass() != o.getClass()) {
51+
return false;
52+
}
53+
RecommendUpdatedAtResponse recommendUpdatedAtResponse = (RecommendUpdatedAtResponse) o;
54+
return (
55+
Objects.equals(this.taskID, recommendUpdatedAtResponse.taskID) && Objects.equals(this.updatedAt, recommendUpdatedAtResponse.updatedAt)
56+
);
57+
}
58+
59+
@Override
60+
public int hashCode() {
61+
return Objects.hash(taskID, updatedAt);
62+
}
63+
64+
@Override
65+
public String toString() {
66+
StringBuilder sb = new StringBuilder();
67+
sb.append("class RecommendUpdatedAtResponse {\n");
68+
sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n");
69+
sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n");
70+
sb.append("}");
71+
return sb.toString();
72+
}
73+
74+
/**
75+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
76+
*/
77+
private String toIndentedString(Object o) {
78+
if (o == null) {
79+
return "null";
80+
}
81+
return o.toString().replace("\n", "\n ");
82+
}
83+
}

0 commit comments

Comments
 (0)