Skip to content

Commit 88f0837

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 eba9f9a commit 88f0837

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

client/src/commonMain/kotlin/com/algolia/client/api/RecommendClient.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@ public class RecommendClient(
3131
).apply { shuffle() }
3232
}
3333

34+
/**
35+
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to match the data source item's attributes instead).
36+
*
37+
* Required API Key ACLs:
38+
* - editSettings
39+
* @param indexName Name of the index on which to perform the operation.
40+
* @param model [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
41+
* @param recommendRule
42+
* @param requestOptions additional request configuration.
43+
*/
44+
public suspend fun batchRecommendRules(indexName: String, model: RecommendModels, recommendRule: List<RecommendRule>? = null, requestOptions: RequestOptions? = null): RecommendUpdatedAtResponse {
45+
require(indexName.isNotBlank()) { "Parameter `indexName` is required when calling `batchRecommendRules`." }
46+
val requestConfig = RequestConfig(
47+
method = RequestMethod.POST,
48+
path = listOf("1", "indexes", "$indexName", "$model", "recommend", "rules", "batch"),
49+
body = recommendRule,
50+
)
51+
return requester.execute(
52+
requestConfig = requestConfig,
53+
requestOptions = requestOptions,
54+
)
55+
}
56+
3457
/**
3558
* This method allow you to send requests to the Algolia REST API.
3659
* @param path Path of the endpoint, anything after \"/1\" must be specified.

client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendRule.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlinx.serialization.json.*
1313
* @param consequence
1414
* @param description Description of the rule's purpose. This can be helpful for display in the Algolia dashboard.
1515
* @param enabled Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.
16+
* @param validity Time periods when the rule is active.
1617
*/
1718
@Serializable
1819
public data class RecommendRule(
@@ -31,4 +32,7 @@ public data class RecommendRule(
3132

3233
/** Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time. */
3334
@SerialName(value = "enabled") val enabled: Boolean? = null,
35+
36+
/** Time periods when the rule is active. */
37+
@SerialName(value = "validity") val validity: List<TimeRange>? = null,
3438
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
2+
package com.algolia.client.model.recommend
3+
4+
import kotlinx.serialization.*
5+
import kotlinx.serialization.json.*
6+
7+
/**
8+
* Response, taskID, and update timestamp.
9+
*
10+
* @param taskID Unique identifier of a task. A successful API response means that a task was added to a queue. It might not run immediately. You can check the task's progress with the [`task` operation](#tag/Indices/operation/getTask) and this `taskID`.
11+
* @param updatedAt Date and time when the object was updated, in RFC 3339 format.
12+
*/
13+
@Serializable
14+
public data class RecommendUpdatedAtResponse(
15+
16+
/** Unique identifier of a task. A successful API response means that a task was added to a queue. It might not run immediately. You can check the task's progress with the [`task` operation](#tag/Indices/operation/getTask) and this `taskID`. */
17+
@SerialName(value = "taskID") val taskID: Long,
18+
19+
/** Date and time when the object was updated, in RFC 3339 format. */
20+
@SerialName(value = "updatedAt") val updatedAt: String,
21+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
2+
package com.algolia.client.model.recommend
3+
4+
import kotlinx.serialization.*
5+
import kotlinx.serialization.json.*
6+
7+
/**
8+
* TimeRange
9+
*
10+
* @param from When the rule should start to be active, in Unix epoch time.
11+
* @param until When the rule should stop to be active, in Unix epoch time.
12+
*/
13+
@Serializable
14+
public data class TimeRange(
15+
16+
/** When the rule should start to be active, in Unix epoch time. */
17+
@SerialName(value = "from") val from: Int,
18+
19+
/** When the rule should stop to be active, in Unix epoch time. */
20+
@SerialName(value = "until") val until: Int,
21+
)

0 commit comments

Comments
 (0)