Skip to content

Commit 86ae17c

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 0ef99a5 commit 86ae17c

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed

src/main/scala/algoliasearch/api/RecommendClient.scala

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import algoliasearch.recommend.GetRecommendationsParams
1010
import algoliasearch.recommend.GetRecommendationsResponse
1111
import algoliasearch.recommend.RecommendModels._
1212
import algoliasearch.recommend.RecommendRule
13+
import algoliasearch.recommend.RecommendUpdatedAtResponse
1314
import algoliasearch.recommend.SearchRecommendRulesParams
1415
import algoliasearch.recommend.SearchRecommendRulesResponse
1516
import algoliasearch.recommend._
@@ -71,6 +72,42 @@ class RecommendClient(
7172
options = clientOptions
7273
) {
7374

75+
/** Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a
76+
* Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in
77+
* which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to
78+
* Search Rules, except that the conditions and consequences apply to a [source
79+
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the
80+
* following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source
81+
* item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only
82+
* covers filtering parameters. - Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it
83+
* tries to match the data source item's attributes instead).
84+
*
85+
* Required API Key ACLs:
86+
* - editSettings
87+
*
88+
* @param indexName
89+
* Name of the index on which to perform the operation.
90+
* @param model
91+
* [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
92+
*/
93+
def batchRecommendRules(
94+
indexName: String,
95+
model: RecommendModels,
96+
recommendRule: Option[Seq[RecommendRule]] = None,
97+
requestOptions: Option[RequestOptions] = None
98+
)(implicit ec: ExecutionContext): Future[RecommendUpdatedAtResponse] = Future {
99+
requireNotNull(indexName, "Parameter `indexName` is required when calling `batchRecommendRules`.")
100+
requireNotNull(model, "Parameter `model` is required when calling `batchRecommendRules`.")
101+
102+
val request = HttpRequest
103+
.builder()
104+
.withMethod("POST")
105+
.withPath(s"/1/indexes/${escape(indexName)}/${escape(model)}/recommend/rules/batch")
106+
.withBody(recommendRule)
107+
.build()
108+
execute[RecommendUpdatedAtResponse](request, requestOptions)
109+
}
110+
74111
/** This method allow you to send requests to the Algolia REST API.
75112
*
76113
* @param path

src/main/scala/algoliasearch/recommend/RecommendRule.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ package algoliasearch.recommend
3737
* Description of the rule's purpose. This can be helpful for display in the Algolia dashboard.
3838
* @param enabled
3939
* Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.
40+
* @param validity
41+
* Time periods when the rule is active.
4042
*/
4143
case class RecommendRule(
4244
metadata: Option[RuleMetadata] = scala.None,
4345
objectID: Option[String] = scala.None,
4446
condition: Option[Condition] = scala.None,
4547
consequence: Option[Consequence] = scala.None,
4648
description: Option[String] = scala.None,
47-
enabled: Option[Boolean] = scala.None
49+
enabled: Option[Boolean] = scala.None,
50+
validity: Option[Seq[TimeRange]] = scala.None
4851
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/** Recommend API The Recommend API lets you retrieve recommendations from one of Algolia's AI recommendation models
2+
* that you previously trained on your data. ## Client libraries Use Algolia's API clients and libraries to reliably
3+
* integrate Algolia's APIs with your apps. The official API clients are covered by Algolia's [Service Level
4+
* Agreement](https://www.algolia.com/policies/sla/). See: [Algolia's
5+
* ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) ## Base URLs
6+
* The base URLs for requests to the Recommend API are: - `https://{APPLICATION_ID}.algolia.net` -
7+
* `https://{APPLICATION_ID}-dsn.algolia.net`. If your subscription includes a [Distributed Search
8+
* Network](https://dashboard.algolia.com/infra), this ensures that requests are sent to servers closest to users. Both
9+
* URLs provide high availability by distributing requests with load balancing. **All requests must use HTTPS.** ##
10+
* Retry strategy To guarantee a high availability, implement a retry strategy for all API requests using the URLs of
11+
* your servers as fallbacks: - `https://{APPLICATION_ID}-1.algolianet.com` -
12+
* `https://{APPLICATION_ID}-2.algolianet.com` - `https://{APPLICATION_ID}-3.algolianet.com` These URLs use a different
13+
* DNS provider than the primary URLs. You should randomize this list to ensure an even load across the three servers.
14+
* All Algolia API clients implement this retry strategy. ## Authentication To authenticate your API requests, add
15+
* these headers: - `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the
16+
* necessary permissions to make the request. The required access control list (ACL) to make a request is listed in
17+
* each endpoint's reference. You can find your application ID and API key in the [Algolia
18+
* dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must be JSON objects. ##
19+
* Response status and errors The Recommend API returns JSON responses. Since JSON doesn't guarantee any specific
20+
* ordering, don't rely on the order of attributes in the API response. Successful responses return a `2xx` status.
21+
* Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
22+
* property with more information. ## Version The current version of the Recommend API is version 1, as indicated by
23+
* the `/1/` in each endpoint's URL.
24+
*
25+
* The version of the OpenAPI document: 1.0.0
26+
*
27+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
28+
* https://openapi-generator.tech Do not edit the class manually.
29+
*/
30+
package algoliasearch.recommend
31+
32+
/** Response, taskID, and update timestamp.
33+
*
34+
* @param taskID
35+
* Unique identifier of a task. A successful API response means that a task was added to a queue. It might not run
36+
* immediately. You can check the task's progress with the [`task` operation](#tag/Indices/operation/getTask) and
37+
* this `taskID`.
38+
* @param updatedAt
39+
* Date and time when the object was updated, in RFC 3339 format.
40+
*/
41+
case class RecommendUpdatedAtResponse(
42+
taskID: Long,
43+
updatedAt: String
44+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** Recommend API The Recommend API lets you retrieve recommendations from one of Algolia's AI recommendation models
2+
* that you previously trained on your data. ## Client libraries Use Algolia's API clients and libraries to reliably
3+
* integrate Algolia's APIs with your apps. The official API clients are covered by Algolia's [Service Level
4+
* Agreement](https://www.algolia.com/policies/sla/). See: [Algolia's
5+
* ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) ## Base URLs
6+
* The base URLs for requests to the Recommend API are: - `https://{APPLICATION_ID}.algolia.net` -
7+
* `https://{APPLICATION_ID}-dsn.algolia.net`. If your subscription includes a [Distributed Search
8+
* Network](https://dashboard.algolia.com/infra), this ensures that requests are sent to servers closest to users. Both
9+
* URLs provide high availability by distributing requests with load balancing. **All requests must use HTTPS.** ##
10+
* Retry strategy To guarantee a high availability, implement a retry strategy for all API requests using the URLs of
11+
* your servers as fallbacks: - `https://{APPLICATION_ID}-1.algolianet.com` -
12+
* `https://{APPLICATION_ID}-2.algolianet.com` - `https://{APPLICATION_ID}-3.algolianet.com` These URLs use a different
13+
* DNS provider than the primary URLs. You should randomize this list to ensure an even load across the three servers.
14+
* All Algolia API clients implement this retry strategy. ## Authentication To authenticate your API requests, add
15+
* these headers: - `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the
16+
* necessary permissions to make the request. The required access control list (ACL) to make a request is listed in
17+
* each endpoint's reference. You can find your application ID and API key in the [Algolia
18+
* dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must be JSON objects. ##
19+
* Response status and errors The Recommend API returns JSON responses. Since JSON doesn't guarantee any specific
20+
* ordering, don't rely on the order of attributes in the API response. Successful responses return a `2xx` status.
21+
* Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
22+
* property with more information. ## Version The current version of the Recommend API is version 1, as indicated by
23+
* the `/1/` in each endpoint's URL.
24+
*
25+
* The version of the OpenAPI document: 1.0.0
26+
*
27+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
28+
* https://openapi-generator.tech Do not edit the class manually.
29+
*/
30+
package algoliasearch.recommend
31+
32+
/** TimeRange
33+
*
34+
* @param from
35+
* When the rule should start to be active, in Unix epoch time.
36+
* @param until
37+
* When the rule should stop to be active, in Unix epoch time.
38+
*/
39+
case class TimeRange(
40+
from: Int,
41+
until: Int
42+
)

0 commit comments

Comments
 (0)