Skip to content

Commit df93536

Browse files
fix(specs): consequence is required when saving rules (#4146) (generated) [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent b728c5f commit df93536

File tree

50 files changed

+580
-223
lines changed

Some content is hidden

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

50 files changed

+580
-223
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Models/Search/Rule.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ public Rule() { }
2525
/// Initializes a new instance of the Rule class.
2626
/// </summary>
2727
/// <param name="objectID">Unique identifier of a rule object. (required).</param>
28-
public Rule(string objectID)
28+
/// <param name="consequence">consequence (required).</param>
29+
public Rule(string objectID, Consequence consequence)
2930
{
3031
ObjectID = objectID ?? throw new ArgumentNullException(nameof(objectID));
32+
Consequence = consequence ?? throw new ArgumentNullException(nameof(consequence));
3133
}
3234

3335
/// <summary>

clients/algoliasearch-client-dart/packages/client_search/lib/src/model/rule.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Rule {
1414
const Rule({
1515
required this.objectID,
1616
this.conditions,
17-
this.consequence,
17+
required this.consequence,
1818
this.description,
1919
this.enabled,
2020
this.validity,
@@ -29,7 +29,7 @@ final class Rule {
2929
final List<Condition>? conditions;
3030

3131
@JsonKey(name: r'consequence')
32-
final Consequence? consequence;
32+
final Consequence consequence;
3333

3434
/// Description of the rule's purpose to help you distinguish between different rules.
3535
@JsonKey(name: r'description')

clients/algoliasearch-client-dart/packages/client_search/lib/src/model/rule.g.dart

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-go/algolia/search/model_rule.go

Lines changed: 14 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/search/Rule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Rule setConsequence(Consequence consequence) {
7070
}
7171

7272
/** Get consequence */
73-
@javax.annotation.Nullable
73+
@javax.annotation.Nonnull
7474
public Consequence getConsequence() {
7575
return consequence;
7676
}

clients/algoliasearch-client-javascript/packages/algoliasearch/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/lite/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/lite/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-abtesting/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-analytics/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-composition/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-insights/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-personalization/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-query-suggestions/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type Rule = {
1818
*/
1919
conditions?: Array<Condition>;
2020

21-
consequence?: Consequence;
21+
consequence: Consequence;
2222

2323
/**
2424
* Description of the rule\'s purpose to help you distinguish between different rules.

clients/algoliasearch-client-javascript/packages/client-search/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,9 @@ export function createSearchClient({
23462346
if (!rule.objectID) {
23472347
throw new Error('Parameter `rule.objectID` is required when calling `saveRule`.');
23482348
}
2349+
if (!rule.consequence) {
2350+
throw new Error('Parameter `rule.consequence` is required when calling `saveRule`.');
2351+
}
23492352

23502353
const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
23512354
.replace('{indexName}', encodeURIComponent(indexName))

clients/algoliasearch-client-javascript/packages/ingestion/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/monitoring/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-javascript/packages/recommend/rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default [
22
{
33
input: 'dist/builds/browser.min.js',
44
external: ['dom'],
5+
cache: false,
56
output: {
67
esModule: false,
78
file: 'dist/builds/browser.umd.js',

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/Rule.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import kotlinx.serialization.json.*
88
* Rule object.
99
*
1010
* @param objectID Unique identifier of a rule object.
11-
* @param conditions Conditions that trigger a rule. Some consequences require specific conditions or don't require any condition. For more information, see [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions).
1211
* @param consequence
12+
* @param conditions Conditions that trigger a rule. Some consequences require specific conditions or don't require any condition. For more information, see [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions).
1313
* @param description Description of the rule's purpose to help you distinguish between different rules.
1414
* @param enabled Whether the rule is active.
1515
* @param validity Time periods when the rule is active.
@@ -20,11 +20,11 @@ public data class Rule(
2020
/** Unique identifier of a rule object. */
2121
@SerialName(value = "objectID") val objectID: String,
2222

23+
@SerialName(value = "consequence") val consequence: Consequence,
24+
2325
/** Conditions that trigger a rule. Some consequences require specific conditions or don't require any condition. For more information, see [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions). */
2426
@SerialName(value = "conditions") val conditions: List<Condition>? = null,
2527

26-
@SerialName(value = "consequence") val consequence: Consequence? = null,
27-
2828
/** Description of the rule's purpose to help you distinguish between different rules. */
2929
@SerialName(value = "description") val description: String? = null,
3030

clients/algoliasearch-client-php/lib/Api/SearchClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ public function saveObject($indexName, $body, $requestOptions = [])
20412041
* @param array $rule rule (required)
20422042
* - $rule['objectID'] => (string) Unique identifier of a rule object. (required)
20432043
* - $rule['conditions'] => (array) Conditions that trigger a rule. Some consequences require specific conditions or don't require any condition. For more information, see [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions).
2044-
* - $rule['consequence'] => (array)
2044+
* - $rule['consequence'] => (array) (required)
20452045
* - $rule['description'] => (string) Description of the rule's purpose to help you distinguish between different rules.
20462046
* - $rule['enabled'] => (bool) Whether the rule is active.
20472047
* - $rule['validity'] => (array) Time periods when the rule is active.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ public function listInvalidProperties()
184184
if (!isset($this->container['objectID']) || null === $this->container['objectID']) {
185185
$invalidProperties[] = "'objectID' can't be null";
186186
}
187+
if (!isset($this->container['consequence']) || null === $this->container['consequence']) {
188+
$invalidProperties[] = "'consequence' can't be null";
189+
}
187190

188191
return $invalidProperties;
189192
}
@@ -250,7 +253,7 @@ public function setConditions($conditions)
250253
/**
251254
* Gets consequence.
252255
*
253-
* @return null|Consequence
256+
* @return Consequence
254257
*/
255258
public function getConsequence()
256259
{
@@ -260,7 +263,7 @@ public function getConsequence()
260263
/**
261264
* Sets consequence.
262265
*
263-
* @param null|Consequence $consequence consequence
266+
* @param Consequence $consequence consequence
264267
*
265268
* @return self
266269
*/

clients/algoliasearch-client-python/algoliasearch/search/models/rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Rule(BaseModel):
4545
""" Unique identifier of a rule object. """
4646
conditions: Optional[List[Condition]] = None
4747
""" Conditions that trigger a rule. Some consequences require specific conditions or don't require any condition. For more information, see [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions). """
48-
consequence: Optional[Consequence] = None
48+
consequence: Consequence
4949
description: Optional[str] = None
5050
""" Description of the rule's purpose to help you distinguish between different rules. """
5151
enabled: Optional[bool] = None

clients/algoliasearch-client-ruby/lib/algolia/models/search/rule.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def initialize(attributes = {})
9494

9595
if attributes.key?(:consequence)
9696
self.consequence = attributes[:consequence]
97+
else
98+
self.consequence = nil
9799
end
98100

99101
if attributes.key?(:description)

clients/algoliasearch-client-scala/src/main/scala/algoliasearch/search/Rule.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ package algoliasearch.search
5151
case class Rule(
5252
objectID: String,
5353
conditions: Option[Seq[Condition]] = scala.None,
54-
consequence: Option[Consequence] = scala.None,
54+
consequence: Consequence,
5555
description: Option[String] = scala.None,
5656
enabled: Option[Boolean] = scala.None,
5757
validity: Option[Seq[TimeRange]] = scala.None

clients/algoliasearch-client-swift/Sources/Search/Models/Rule.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct Rule: Codable, JSONEncodable {
1414
/// For more information, see
1515
/// [Conditions](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/#conditions).
1616
public var conditions: [SearchCondition]?
17-
public var consequence: SearchConsequence?
17+
public var consequence: SearchConsequence
1818
/// Description of the rule's purpose to help you distinguish between different rules.
1919
public var description: String?
2020
/// Whether the rule is active.
@@ -25,7 +25,7 @@ public struct Rule: Codable, JSONEncodable {
2525
public init(
2626
objectID: String,
2727
conditions: [SearchCondition]? = nil,
28-
consequence: SearchConsequence? = nil,
28+
consequence: SearchConsequence,
2929
description: String? = nil,
3030
enabled: Bool? = nil,
3131
validity: [SearchTimeRange]? = nil
@@ -53,7 +53,7 @@ public struct Rule: Codable, JSONEncodable {
5353
var container = encoder.container(keyedBy: CodingKeys.self)
5454
try container.encode(self.objectID, forKey: .objectID)
5555
try container.encodeIfPresent(self.conditions, forKey: .conditions)
56-
try container.encodeIfPresent(self.consequence, forKey: .consequence)
56+
try container.encode(self.consequence, forKey: .consequence)
5757
try container.encodeIfPresent(self.description, forKey: .description)
5858
try container.encodeIfPresent(self.enabled, forKey: .enabled)
5959
try container.encodeIfPresent(self.validity, forKey: .validity)
@@ -75,7 +75,7 @@ extension Rule: Hashable {
7575
public func hash(into hasher: inout Hasher) {
7676
hasher.combine(self.objectID.hashValue)
7777
hasher.combine(self.conditions?.hashValue)
78-
hasher.combine(self.consequence?.hashValue)
78+
hasher.combine(self.consequence.hashValue)
7979
hasher.combine(self.description?.hashValue)
8080
hasher.combine(self.enabled?.hashValue)
8181
hasher.combine(self.validity?.hashValue)

0 commit comments

Comments
 (0)