Skip to content

Commit 20b147d

Browse files
algolia-botraed667millotpshortcuts
committed
feat(specs): add recommend batch rules endpoint (#3782) (generated) [skip ci]
Co-authored-by: Raed <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent dc28c02 commit 20b147d

File tree

80 files changed

+4219
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4219
-36
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Clients/RecommendClient.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,40 @@ namespace Algolia.Search.Clients;
2121
/// </summary>
2222
public interface IRecommendClient
2323
{
24+
/// <summary>
25+
/// 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).
26+
/// </summary>
27+
///
28+
/// Required API Key ACLs:
29+
/// - editSettings
30+
/// <param name="indexName">Name of the index on which to perform the operation.</param>
31+
/// <param name="model">[Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). </param>
32+
/// <param name="recommendRule"> (optional)</param>
33+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
34+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
35+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
36+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
37+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
38+
/// <returns>Task of RecommendUpdatedAtResponse</returns>
39+
Task<RecommendUpdatedAtResponse> BatchRecommendRulesAsync(string indexName, RecommendModels model, List<RecommendRule> recommendRule = default, RequestOptions options = null, CancellationToken cancellationToken = default);
40+
41+
/// <summary>
42+
/// 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). (Synchronous version)
43+
/// </summary>
44+
///
45+
/// Required API Key ACLs:
46+
/// - editSettings
47+
/// <param name="indexName">Name of the index on which to perform the operation.</param>
48+
/// <param name="model">[Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). </param>
49+
/// <param name="recommendRule"> (optional)</param>
50+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
51+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
52+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
53+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
54+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
55+
/// <returns>RecommendUpdatedAtResponse</returns>
56+
RecommendUpdatedAtResponse BatchRecommendRules(string indexName, RecommendModels model, List<RecommendRule> recommendRule = default, RequestOptions options = null, CancellationToken cancellationToken = default);
57+
2458
/// <summary>
2559
/// This method allow you to send requests to the Algolia REST API.
2660
/// </summary>
@@ -374,6 +408,29 @@ public void SetClientApiKey(string apiKey)
374408

375409

376410

411+
/// <inheritdoc />
412+
public async Task<RecommendUpdatedAtResponse> BatchRecommendRulesAsync(string indexName, RecommendModels model, List<RecommendRule> recommendRule = default, RequestOptions options = null, CancellationToken cancellationToken = default)
413+
{
414+
415+
if (indexName == null)
416+
throw new ArgumentException("Parameter `indexName` is required when calling `BatchRecommendRules`.");
417+
418+
419+
var requestOptions = new InternalRequestOptions(options);
420+
421+
requestOptions.PathParameters.Add("indexName", QueryStringHelper.ParameterToString(indexName));
422+
requestOptions.PathParameters.Add("model", QueryStringHelper.ParameterToString(model));
423+
424+
requestOptions.Data = recommendRule;
425+
return await _transport.ExecuteRequestAsync<RecommendUpdatedAtResponse>(new HttpMethod("POST"), "/1/indexes/{indexName}/{model}/recommend/rules/batch", requestOptions, cancellationToken).ConfigureAwait(false);
426+
}
427+
428+
429+
/// <inheritdoc />
430+
public RecommendUpdatedAtResponse BatchRecommendRules(string indexName, RecommendModels model, List<RecommendRule> recommendRule = default, RequestOptions options = null, CancellationToken cancellationToken = default) =>
431+
AsyncHelper.RunSync(() => BatchRecommendRulesAsync(indexName, model, recommendRule, options, cancellationToken));
432+
433+
377434
/// <inheritdoc />
378435
public async Task<object> CustomDeleteAsync(string path, Dictionary<string, object> parameters = default, RequestOptions options = null, CancellationToken cancellationToken = default)
379436
{

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RecommendRule.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ public RecommendRule()
6262
[JsonPropertyName("enabled")]
6363
public bool? Enabled { get; set; }
6464

65+
/// <summary>
66+
/// Time periods when the rule is active.
67+
/// </summary>
68+
/// <value>Time periods when the rule is active.</value>
69+
[JsonPropertyName("validity")]
70+
public List<TimeRange> Validity { get; set; }
71+
6572
/// <summary>
6673
/// Returns the string presentation of the object
6774
/// </summary>
@@ -76,6 +83,7 @@ public override string ToString()
7683
sb.Append(" Consequence: ").Append(Consequence).Append("\n");
7784
sb.Append(" Description: ").Append(Description).Append("\n");
7885
sb.Append(" Enabled: ").Append(Enabled).Append("\n");
86+
sb.Append(" Validity: ").Append(Validity).Append("\n");
7987
sb.Append("}\n");
8088
return sb.ToString();
8189
}
@@ -107,7 +115,8 @@ public override bool Equals(object obj)
107115
(Condition == input.Condition || (Condition != null && Condition.Equals(input.Condition))) &&
108116
(Consequence == input.Consequence || (Consequence != null && Consequence.Equals(input.Consequence))) &&
109117
(Description == input.Description || (Description != null && Description.Equals(input.Description))) &&
110-
(Enabled == input.Enabled || Enabled.Equals(input.Enabled));
118+
(Enabled == input.Enabled || Enabled.Equals(input.Enabled)) &&
119+
(Validity == input.Validity || Validity != null && input.Validity != null && Validity.SequenceEqual(input.Validity));
111120
}
112121

113122
/// <summary>
@@ -140,6 +149,10 @@ public override int GetHashCode()
140149
hashCode = (hashCode * 59) + Description.GetHashCode();
141150
}
142151
hashCode = (hashCode * 59) + Enabled.GetHashCode();
152+
if (Validity != null)
153+
{
154+
hashCode = (hashCode * 59) + Validity.GetHashCode();
155+
}
143156
return hashCode;
144157
}
145158
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Recommend;
13+
14+
/// <summary>
15+
/// Response, taskID, and update timestamp.
16+
/// </summary>
17+
public partial class RecommendUpdatedAtResponse
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the RecommendUpdatedAtResponse class.
21+
/// </summary>
22+
[JsonConstructor]
23+
public RecommendUpdatedAtResponse() { }
24+
/// <summary>
25+
/// Initializes a new instance of the RecommendUpdatedAtResponse class.
26+
/// </summary>
27+
/// <param name="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&#39;s progress with the [&#x60;task&#x60; operation](#tag/Indices/operation/getTask) and this &#x60;taskID&#x60;. (required).</param>
28+
/// <param name="updatedAt">Date and time when the object was updated, in RFC 3339 format. (required).</param>
29+
public RecommendUpdatedAtResponse(long taskID, string updatedAt)
30+
{
31+
TaskID = taskID;
32+
UpdatedAt = updatedAt ?? throw new ArgumentNullException(nameof(updatedAt));
33+
}
34+
35+
/// <summary>
36+
/// 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`.
37+
/// </summary>
38+
/// <value>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`. </value>
39+
[JsonPropertyName("taskID")]
40+
public long TaskID { get; set; }
41+
42+
/// <summary>
43+
/// Date and time when the object was updated, in RFC 3339 format.
44+
/// </summary>
45+
/// <value>Date and time when the object was updated, in RFC 3339 format.</value>
46+
[JsonPropertyName("updatedAt")]
47+
public string UpdatedAt { get; set; }
48+
49+
/// <summary>
50+
/// Returns the string presentation of the object
51+
/// </summary>
52+
/// <returns>String presentation of the object</returns>
53+
public override string ToString()
54+
{
55+
StringBuilder sb = new StringBuilder();
56+
sb.Append("class RecommendUpdatedAtResponse {\n");
57+
sb.Append(" TaskID: ").Append(TaskID).Append("\n");
58+
sb.Append(" UpdatedAt: ").Append(UpdatedAt).Append("\n");
59+
sb.Append("}\n");
60+
return sb.ToString();
61+
}
62+
63+
/// <summary>
64+
/// Returns the JSON string presentation of the object
65+
/// </summary>
66+
/// <returns>JSON string presentation of the object</returns>
67+
public virtual string ToJson()
68+
{
69+
return JsonSerializer.Serialize(this, JsonConfig.Options);
70+
}
71+
72+
/// <summary>
73+
/// Returns true if objects are equal
74+
/// </summary>
75+
/// <param name="obj">Object to be compared</param>
76+
/// <returns>Boolean</returns>
77+
public override bool Equals(object obj)
78+
{
79+
if (obj is not RecommendUpdatedAtResponse input)
80+
{
81+
return false;
82+
}
83+
84+
return
85+
(TaskID == input.TaskID || TaskID.Equals(input.TaskID)) &&
86+
(UpdatedAt == input.UpdatedAt || (UpdatedAt != null && UpdatedAt.Equals(input.UpdatedAt)));
87+
}
88+
89+
/// <summary>
90+
/// Gets the hash code
91+
/// </summary>
92+
/// <returns>Hash code</returns>
93+
public override int GetHashCode()
94+
{
95+
unchecked // Overflow is fine, just wrap
96+
{
97+
int hashCode = 41;
98+
hashCode = (hashCode * 59) + TaskID.GetHashCode();
99+
if (UpdatedAt != null)
100+
{
101+
hashCode = (hashCode * 59) + UpdatedAt.GetHashCode();
102+
}
103+
return hashCode;
104+
}
105+
}
106+
107+
}
108+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Recommend;
13+
14+
/// <summary>
15+
/// TimeRange
16+
/// </summary>
17+
public partial class TimeRange
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the TimeRange class.
21+
/// </summary>
22+
[JsonConstructor]
23+
public TimeRange() { }
24+
/// <summary>
25+
/// Initializes a new instance of the TimeRange class.
26+
/// </summary>
27+
/// <param name="from">When the rule should start to be active, in Unix epoch time. (required).</param>
28+
/// <param name="until">When the rule should stop to be active, in Unix epoch time. (required).</param>
29+
public TimeRange(int from, int until)
30+
{
31+
From = from;
32+
Until = until;
33+
}
34+
35+
/// <summary>
36+
/// When the rule should start to be active, in Unix epoch time.
37+
/// </summary>
38+
/// <value>When the rule should start to be active, in Unix epoch time.</value>
39+
[JsonPropertyName("from")]
40+
public int From { get; set; }
41+
42+
/// <summary>
43+
/// When the rule should stop to be active, in Unix epoch time.
44+
/// </summary>
45+
/// <value>When the rule should stop to be active, in Unix epoch time.</value>
46+
[JsonPropertyName("until")]
47+
public int Until { get; set; }
48+
49+
/// <summary>
50+
/// Returns the string presentation of the object
51+
/// </summary>
52+
/// <returns>String presentation of the object</returns>
53+
public override string ToString()
54+
{
55+
StringBuilder sb = new StringBuilder();
56+
sb.Append("class TimeRange {\n");
57+
sb.Append(" From: ").Append(From).Append("\n");
58+
sb.Append(" Until: ").Append(Until).Append("\n");
59+
sb.Append("}\n");
60+
return sb.ToString();
61+
}
62+
63+
/// <summary>
64+
/// Returns the JSON string presentation of the object
65+
/// </summary>
66+
/// <returns>JSON string presentation of the object</returns>
67+
public virtual string ToJson()
68+
{
69+
return JsonSerializer.Serialize(this, JsonConfig.Options);
70+
}
71+
72+
/// <summary>
73+
/// Returns true if objects are equal
74+
/// </summary>
75+
/// <param name="obj">Object to be compared</param>
76+
/// <returns>Boolean</returns>
77+
public override bool Equals(object obj)
78+
{
79+
if (obj is not TimeRange input)
80+
{
81+
return false;
82+
}
83+
84+
return
85+
(From == input.From || From.Equals(input.From)) &&
86+
(Until == input.Until || Until.Equals(input.Until));
87+
}
88+
89+
/// <summary>
90+
/// Gets the hash code
91+
/// </summary>
92+
/// <returns>Hash code</returns>
93+
public override int GetHashCode()
94+
{
95+
unchecked // Overflow is fine, just wrap
96+
{
97+
int hashCode = 41;
98+
hashCode = (hashCode * 59) + From.GetHashCode();
99+
hashCode = (hashCode * 59) + Until.GetHashCode();
100+
return hashCode;
101+
}
102+
}
103+
104+
}
105+

clients/algoliasearch-client-dart/packages/client_recommend/lib/algolia_client_recommend.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export 'src/model/recommend_index_settings.dart';
4949
export 'src/model/recommend_models.dart';
5050
export 'src/model/recommend_rule.dart';
5151
export 'src/model/recommend_search_params.dart';
52+
export 'src/model/recommend_updated_at_response.dart';
5253
export 'src/model/recommendations_hits.dart';
5354
export 'src/model/recommendations_results.dart';
5455
export 'src/model/recommended_for_you.dart';
@@ -72,6 +73,7 @@ export 'src/model/snippet_result_option.dart';
7273
export 'src/model/sort_remaining_by.dart';
7374
export 'src/model/supported_language.dart';
7475
export 'src/model/task_status.dart';
76+
export 'src/model/time_range.dart';
7577
export 'src/model/trending_facet_hit.dart';
7678
export 'src/model/trending_facets.dart';
7779
export 'src/model/trending_facets_model.dart';

clients/algoliasearch-client-dart/packages/client_recommend/lib/src/api/recommend_client.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:algolia_client_recommend/src/model/get_recommendations_params.da
1010
import 'package:algolia_client_recommend/src/model/get_recommendations_response.dart';
1111
import 'package:algolia_client_recommend/src/model/recommend_models.dart';
1212
import 'package:algolia_client_recommend/src/model/recommend_rule.dart';
13+
import 'package:algolia_client_recommend/src/model/recommend_updated_at_response.dart';
1314
import 'package:algolia_client_recommend/src/model/search_recommend_rules_params.dart';
1415
import 'package:algolia_client_recommend/src/model/search_recommend_rules_response.dart';
1516

@@ -49,6 +50,45 @@ final class RecommendClient implements ApiClient {
4950
_retryStrategy.requester.setClientApiKey(apiKey);
5051
}
5152

53+
/// 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).
54+
///
55+
/// Required API Key ACLs:
56+
/// - editSettings
57+
///
58+
/// Parameters:
59+
/// * [indexName] Name of the index on which to perform the operation.
60+
/// * [model] [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
61+
/// * [recommendRule]
62+
/// * [requestOptions] additional request configuration.
63+
Future<RecommendUpdatedAtResponse> batchRecommendRules({
64+
required String indexName,
65+
required RecommendModels model,
66+
List<RecommendRule>? recommendRule,
67+
RequestOptions? requestOptions,
68+
}) async {
69+
assert(
70+
indexName.isNotEmpty,
71+
'Parameter `indexName` is required when calling `batchRecommendRules`.',
72+
);
73+
final request = ApiRequest(
74+
method: RequestMethod.post,
75+
path: r'/1/indexes/{indexName}/{model}/recommend/rules/batch'
76+
.replaceAll(
77+
'{' r'indexName' '}', Uri.encodeComponent(indexName.toString()))
78+
.replaceAll('{' r'model' '}', Uri.encodeComponent(model.toString())),
79+
body: recommendRule,
80+
);
81+
final response = await _retryStrategy.execute(
82+
request: request,
83+
options: requestOptions,
84+
);
85+
return deserialize<RecommendUpdatedAtResponse, RecommendUpdatedAtResponse>(
86+
response,
87+
'RecommendUpdatedAtResponse',
88+
growable: true,
89+
);
90+
}
91+
5292
/// This method allow you to send requests to the Algolia REST API.
5393
///
5494
/// Parameters:

0 commit comments

Comments
 (0)