Skip to content

Commit efc5ff6

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 4a4e44c commit efc5ff6

File tree

7 files changed

+111
-13
lines changed

7 files changed

+111
-13
lines changed

packages/algoliasearch/builds/models.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import type {
1212
AroundRadiusAll,
1313
AutomaticFacetFilter,
1414
AutomaticFacetFilters,
15-
BaseSearchParams,
1615
BaseIndexSettings,
16+
BaseSearchParams,
1717
BaseSearchParamsWithoutQuery,
1818
BaseSearchResponse,
1919
BooleanString,
@@ -42,8 +42,8 @@ import type {
4242
HighlightResultOption,
4343
IgnorePlurals,
4444
IndexSettingsAsSearchParams,
45-
MatchLevel,
4645
MatchedGeoLocation,
46+
MatchLevel,
4747
Mode,
4848
NumericFilters,
4949
OptionalFilters,
@@ -55,14 +55,14 @@ import type {
5555
QueryType,
5656
Range,
5757
RankingInfo,
58-
ReRankingApplyFilter,
5958
Redirect,
60-
RedirectRuleIndexMetadata,
6159
RedirectRuleIndexData,
60+
RedirectRuleIndexMetadata,
6261
RedirectURL,
6362
RemoveStopWords,
6463
RemoveWordsIfNoResults,
6564
RenderingContent,
65+
ReRankingApplyFilter,
6666
SearchPagination,
6767
SearchParams,
6868
SearchParamsObject,
@@ -74,6 +74,7 @@ import type {
7474
SupportedLanguage,
7575
TagFilters,
7676
TaskStatus,
77+
TimeRange,
7778
TypoTolerance,
7879
TypoToleranceEnum,
7980
Value,
@@ -89,16 +90,19 @@ export * from '@algolia/client-analytics';
8990
export * from '@algolia/client-abtesting';
9091

9192
export {
93+
AbTestingRegion,
9294
AdvancedSyntaxFeatures,
9395
AlternativesAsExact,
96+
AnalyticsRegion,
9497
Anchoring,
98+
apiClientVersion,
9599
AroundPrecision,
96100
AroundRadius,
97101
AroundRadiusAll,
98102
AutomaticFacetFilter,
99103
AutomaticFacetFilters,
100-
BaseSearchParams,
101104
BaseIndexSettings,
105+
BaseSearchParams,
102106
BaseSearchParamsWithoutQuery,
103107
BaseSearchResponse,
104108
BooleanString,
@@ -127,8 +131,8 @@ export {
127131
HighlightResultOption,
128132
IgnorePlurals,
129133
IndexSettingsAsSearchParams,
130-
MatchLevel,
131134
MatchedGeoLocation,
135+
MatchLevel,
132136
Mode,
133137
NumericFilters,
134138
OptionalFilters,
@@ -140,32 +144,30 @@ export {
140144
QueryType,
141145
Range,
142146
RankingInfo,
143-
ReRankingApplyFilter,
144147
Redirect,
145-
RedirectRuleIndexMetadata,
146148
RedirectRuleIndexData,
149+
RedirectRuleIndexMetadata,
147150
RedirectURL,
151+
Region,
148152
RemoveStopWords,
149153
RemoveWordsIfNoResults,
150154
RenderingContent,
155+
ReRankingApplyFilter,
156+
SearchPagination,
151157
SearchParams,
152158
SearchParamsObject,
153159
SearchParamsQuery,
154160
SemanticSearch,
155-
SearchPagination,
156161
SnippetResult,
157162
SnippetResultOption,
158163
SortRemainingBy,
159164
SupportedLanguage,
160165
TagFilters,
161166
TaskStatus,
167+
TimeRange,
162168
TypoTolerance,
163169
TypoToleranceEnum,
164170
Value,
165-
AnalyticsRegion,
166-
AbTestingRegion,
167-
Region,
168-
apiClientVersion,
169171
};
170172

171173
/**

packages/recommend/model/clientMethodProps.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
// 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.
22

33
import type { RecommendModels } from './recommendModels';
4+
import type { RecommendRule } from './recommendRule';
45
import type { RecommendationsRequest } from './recommendationsRequest';
56
import type { SearchRecommendRulesParams } from './searchRecommendRulesParams';
67

8+
/**
9+
* Properties for the `batchRecommendRules` method.
10+
*/
11+
export type BatchRecommendRulesProps = {
12+
/**
13+
* Name of the index on which to perform the operation.
14+
*/
15+
indexName: string;
16+
/**
17+
* [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
18+
*/
19+
model: RecommendModels;
20+
recommendRule?: RecommendRule[];
21+
};
22+
723
/**
824
* Properties for the `customDelete` method.
925
*/

packages/recommend/model/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export * from './recommendIndexSettings';
5353
export * from './recommendModels';
5454
export * from './recommendRule';
5555
export * from './recommendSearchParams';
56+
export * from './recommendUpdatedAtResponse';
5657
export * from './recommendationsHit';
5758
export * from './recommendationsHits';
5859
export * from './recommendationsRequest';
@@ -81,6 +82,7 @@ export * from './sortRemainingBy';
8182
export * from './supportedLanguage';
8283
export * from './tagFilters';
8384
export * from './taskStatus';
85+
export * from './timeRange';
8486
export * from './trendingFacetHit';
8587
export * from './trendingFacets';
8688
export * from './trendingFacetsModel';

packages/recommend/model/recommendRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import type { Condition } from './condition';
44
import type { Consequence } from './consequence';
55
import type { RuleMetadata } from './ruleMetadata';
6+
import type { TimeRange } from './timeRange';
67

78
/**
89
* Recommend rule.
@@ -28,4 +29,9 @@ export type RecommendRule = {
2829
* Indicates whether to enable the rule. If it isn\'t enabled, it isn\'t applied at query time.
2930
*/
3031
enabled?: boolean;
32+
33+
/**
34+
* Time periods when the rule is active.
35+
*/
36+
validity?: TimeRange[];
3137
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
3+
/**
4+
* Response, taskID, and update timestamp.
5+
*/
6+
export type RecommendUpdatedAtResponse = {
7+
/**
8+
* 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`.
9+
*/
10+
taskID: number;
11+
12+
/**
13+
* Date and time when the object was updated, in RFC 3339 format.
14+
*/
15+
updatedAt: string;
16+
};

packages/recommend/model/timeRange.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
3+
export type TimeRange = {
4+
/**
5+
* When the rule should start to be active, in Unix epoch time.
6+
*/
7+
from: number;
8+
9+
/**
10+
* When the rule should stop to be active, in Unix epoch time.
11+
*/
12+
until: number;
13+
};

packages/recommend/src/recommendClient.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
} from '@algolia/client-common';
1212

1313
import type {
14+
BatchRecommendRulesProps,
1415
CustomDeleteProps,
1516
CustomGetProps,
1617
CustomPostProps,
@@ -26,6 +27,7 @@ import type { GetRecommendTaskResponse } from '../model/getRecommendTaskResponse
2627
import type { GetRecommendationsParams } from '../model/getRecommendationsParams';
2728
import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse';
2829
import type { RecommendRule } from '../model/recommendRule';
30+
import type { RecommendUpdatedAtResponse } from '../model/recommendUpdatedAtResponse';
2931
import type { SearchRecommendRulesResponse } from '../model/searchRecommendRulesResponse';
3032

3133
export const apiClientVersion = '5.6.1';
@@ -139,6 +141,47 @@ export function createRecommendClient({
139141
}
140142
},
141143

144+
/**
145+
* 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).
146+
*
147+
* Required API Key ACLs:
148+
* - editSettings.
149+
*
150+
* @param batchRecommendRules - The batchRecommendRules object.
151+
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation.
152+
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
153+
* @param batchRecommendRules.recommendRule - The recommendRule object.
154+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
155+
*/
156+
batchRecommendRules(
157+
{ indexName, model, recommendRule }: BatchRecommendRulesProps,
158+
requestOptions?: RequestOptions,
159+
): Promise<RecommendUpdatedAtResponse> {
160+
if (!indexName) {
161+
throw new Error('Parameter `indexName` is required when calling `batchRecommendRules`.');
162+
}
163+
164+
if (!model) {
165+
throw new Error('Parameter `model` is required when calling `batchRecommendRules`.');
166+
}
167+
168+
const requestPath = '/1/indexes/{indexName}/{model}/recommend/rules/batch'
169+
.replace('{indexName}', encodeURIComponent(indexName))
170+
.replace('{model}', encodeURIComponent(model));
171+
const headers: Headers = {};
172+
const queryParameters: QueryParameters = {};
173+
174+
const request: Request = {
175+
method: 'POST',
176+
path: requestPath,
177+
queryParameters,
178+
headers,
179+
data: recommendRule ? recommendRule : {},
180+
};
181+
182+
return transporter.request(request, requestOptions);
183+
},
184+
142185
/**
143186
* This method allow you to send requests to the Algolia REST API.
144187
*

0 commit comments

Comments
 (0)