Skip to content

Commit f7e4104

Browse files
author
awstools
committed
feat(client-personalize-runtime): This release provides support for promotions in AWS Personalize runtime.
1 parent efb1eda commit f7e4104

File tree

3 files changed

+154
-3
lines changed

3 files changed

+154
-3
lines changed

clients/client-personalize-runtime/src/models/models_0.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export interface PredictedItem {
6666
* selection. For more information on scoring logic, see <a>how-scores-work</a>.</p>
6767
*/
6868
score?: number;
69+
70+
/**
71+
* <p>The name of the promotion that included the predicted item.</p>
72+
*/
73+
promotionName?: string;
6974
}
7075

7176
export interface GetPersonalizedRankingResponse {
@@ -118,6 +123,41 @@ export class ResourceNotFoundException extends __BaseException {
118123
}
119124
}
120125

126+
/**
127+
* <p>Contains information on a promotion. A promotion defines additional business rules that apply to a configurable subset of recommended items.</p>
128+
*/
129+
export interface Promotion {
130+
/**
131+
* <p>The name of the promotion.</p>
132+
*/
133+
name?: string;
134+
135+
/**
136+
* <p>The percentage of recommended items to apply the promotion to.</p>
137+
*/
138+
percentPromotedItems?: number;
139+
140+
/**
141+
* <p>The Amazon Resource Name (ARN) of the filter used by the promotion. This filter defines the criteria for promoted items. For more information, see
142+
* <a href="https://docs.aws.amazon.com/personalize/latest/dg/promoting-items.html#promotion-filters">Promotion filters</a>.</p>
143+
*/
144+
filterArn?: string;
145+
146+
/**
147+
* <p>The values to use when promoting items.
148+
* For each placeholder parameter in your promotion's filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.
149+
* </p>
150+
* <p>For filter expressions that use an <code>INCLUDE</code> element to include items,
151+
* you must provide values for all parameters that are defined in the expression. For
152+
* filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you
153+
* can omit the <code>filter-values</code>. In this case, Amazon Personalize doesn't use that portion of
154+
* the expression to filter recommendations.</p>
155+
* <p>For more information on creating filters, see
156+
* <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering recommendations and user segments</a>.</p>
157+
*/
158+
filterValues?: Record<string, string>;
159+
}
160+
121161
export interface GetRecommendationsRequest {
122162
/**
123163
* <p>The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.</p>
@@ -165,7 +205,7 @@ export interface GetRecommendationsRequest {
165205
* can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of
166206
* the expression to filter recommendations.</p>
167207
* <p>For more information, see
168-
* <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
208+
* <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering recommendations and user segments</a>.</p>
169209
*/
170210
filterValues?: Record<string, string>;
171211

@@ -174,6 +214,12 @@ export interface GetRecommendationsRequest {
174214
* created a Domain dataset group with a recommender for a domain use case.</p>
175215
*/
176216
recommenderArn?: string;
217+
218+
/**
219+
* <p>The promotions to apply to the recommendation request.
220+
* A promotion defines additional business rules that apply to a configurable subset of recommended items.</p>
221+
*/
222+
promotions?: Promotion[];
177223
}
178224

179225
export interface GetRecommendationsResponse {
@@ -212,13 +258,22 @@ export const GetPersonalizedRankingResponseFilterSensitiveLog = (obj: GetPersona
212258
...obj,
213259
});
214260

261+
/**
262+
* @internal
263+
*/
264+
export const PromotionFilterSensitiveLog = (obj: Promotion): any => ({
265+
...obj,
266+
...(obj.filterValues && { filterValues: SENSITIVE_STRING }),
267+
});
268+
215269
/**
216270
* @internal
217271
*/
218272
export const GetRecommendationsRequestFilterSensitiveLog = (obj: GetRecommendationsRequest): any => ({
219273
...obj,
220274
...(obj.context && { context: SENSITIVE_STRING }),
221275
...(obj.filterValues && { filterValues: SENSITIVE_STRING }),
276+
...(obj.promotions && { promotions: obj.promotions.map((item) => PromotionFilterSensitiveLog(item)) }),
222277
});
223278

224279
/**

clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
GetPersonalizedRankingCommandOutput,
2121
} from "../commands/GetPersonalizedRankingCommand";
2222
import { GetRecommendationsCommandInput, GetRecommendationsCommandOutput } from "../commands/GetRecommendationsCommand";
23-
import { InvalidInputException, PredictedItem, ResourceNotFoundException } from "../models/models_0";
23+
import { InvalidInputException, PredictedItem, Promotion, ResourceNotFoundException } from "../models/models_0";
2424
import { PersonalizeRuntimeServiceException as __BaseException } from "../models/PersonalizeRuntimeServiceException";
2525

2626
export const serializeAws_restJson1GetPersonalizedRankingCommand = async (
@@ -73,6 +73,7 @@ export const serializeAws_restJson1GetRecommendationsCommand = async (
7373
}),
7474
...(input.itemId != null && { itemId: input.itemId }),
7575
...(input.numResults != null && { numResults: input.numResults }),
76+
...(input.promotions != null && { promotions: serializeAws_restJson1PromotionList(input.promotions, context) }),
7677
...(input.recommenderArn != null && { recommenderArn: input.recommenderArn }),
7778
...(input.userId != null && { userId: input.userId }),
7879
});
@@ -246,6 +247,25 @@ const serializeAws_restJson1InputList = (input: string[], context: __SerdeContex
246247
});
247248
};
248249

250+
const serializeAws_restJson1Promotion = (input: Promotion, context: __SerdeContext): any => {
251+
return {
252+
...(input.filterArn != null && { filterArn: input.filterArn }),
253+
...(input.filterValues != null && {
254+
filterValues: serializeAws_restJson1FilterValues(input.filterValues, context),
255+
}),
256+
...(input.name != null && { name: input.name }),
257+
...(input.percentPromotedItems != null && { percentPromotedItems: input.percentPromotedItems }),
258+
};
259+
};
260+
261+
const serializeAws_restJson1PromotionList = (input: Promotion[], context: __SerdeContext): any => {
262+
return input
263+
.filter((e: any) => e != null)
264+
.map((entry) => {
265+
return serializeAws_restJson1Promotion(entry, context);
266+
});
267+
};
268+
249269
const deserializeAws_restJson1ItemList = (output: any, context: __SerdeContext): PredictedItem[] => {
250270
const retVal = (output || [])
251271
.filter((e: any) => e != null)
@@ -261,6 +281,7 @@ const deserializeAws_restJson1ItemList = (output: any, context: __SerdeContext):
261281
const deserializeAws_restJson1PredictedItem = (output: any, context: __SerdeContext): PredictedItem => {
262282
return {
263283
itemId: __expectString(output.itemId),
284+
promotionName: __expectString(output.promotionName),
264285
score: __limitedParseDouble(output.score),
265286
} as any;
266287
};

codegen/sdk-codegen/aws-models/personalize-runtime.json

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,20 @@
294294
"filterValues": {
295295
"target": "com.amazonaws.personalizeruntime#FilterValues",
296296
"traits": {
297-
"smithy.api#documentation": "<p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case)\n as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.\n </p> \n <p>For filter expressions that use an <code>INCLUDE</code> element to include items,\n you must provide values for all parameters that are defined in the expression. For\n filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you\n can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of\n the expression to filter recommendations.</p>\n <p>For more information, see\n <a href=\"https://docs.aws.amazon.com/personalize/latest/dg/filter.html\">Filtering Recommendations</a>.</p>"
297+
"smithy.api#documentation": "<p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case)\n as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.\n </p> \n <p>For filter expressions that use an <code>INCLUDE</code> element to include items,\n you must provide values for all parameters that are defined in the expression. For\n filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you\n can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of\n the expression to filter recommendations.</p>\n <p>For more information, see\n <a href=\"https://docs.aws.amazon.com/personalize/latest/dg/filter.html\">Filtering recommendations and user segments</a>.</p>"
298298
}
299299
},
300300
"recommenderArn": {
301301
"target": "com.amazonaws.personalizeruntime#Arn",
302302
"traits": {
303303
"smithy.api#documentation": "<p>The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you\n created a Domain dataset group with a recommender for a domain use case.</p>"
304304
}
305+
},
306+
"promotions": {
307+
"target": "com.amazonaws.personalizeruntime#PromotionList",
308+
"traits": {
309+
"smithy.api#documentation": "<p>The promotions to apply to the recommendation request. \n A promotion defines additional business rules that apply to a configurable subset of recommended items.</p>"
310+
}
305311
}
306312
}
307313
},
@@ -356,6 +362,16 @@
356362
"target": "com.amazonaws.personalizeruntime#PredictedItem"
357363
}
358364
},
365+
"com.amazonaws.personalizeruntime#Name": {
366+
"type": "string",
367+
"traits": {
368+
"smithy.api#length": {
369+
"min": 1,
370+
"max": 63
371+
},
372+
"smithy.api#pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-_]*$"
373+
}
374+
},
359375
"com.amazonaws.personalizeruntime#NumResults": {
360376
"type": "integer",
361377
"traits": {
@@ -364,6 +380,15 @@
364380
}
365381
}
366382
},
383+
"com.amazonaws.personalizeruntime#PercentPromotedItems": {
384+
"type": "integer",
385+
"traits": {
386+
"smithy.api#range": {
387+
"min": 1,
388+
"max": 100
389+
}
390+
}
391+
},
367392
"com.amazonaws.personalizeruntime#PredictedItem": {
368393
"type": "structure",
369394
"members": {
@@ -378,12 +403,62 @@
378403
"traits": {
379404
"smithy.api#documentation": "<p>A numeric representation of the model's certainty that the item will be the next user\n selection. For more information on scoring logic, see <a>how-scores-work</a>.</p>"
380405
}
406+
},
407+
"promotionName": {
408+
"target": "com.amazonaws.personalizeruntime#Name",
409+
"traits": {
410+
"smithy.api#documentation": "<p>The name of the promotion that included the predicted item.</p>"
411+
}
381412
}
382413
},
383414
"traits": {
384415
"smithy.api#documentation": "<p>An object that identifies an item.</p>\n <p>The and APIs return a list of\n <code>PredictedItem</code>s.</p>"
385416
}
386417
},
418+
"com.amazonaws.personalizeruntime#Promotion": {
419+
"type": "structure",
420+
"members": {
421+
"name": {
422+
"target": "com.amazonaws.personalizeruntime#Name",
423+
"traits": {
424+
"smithy.api#documentation": "<p>The name of the promotion.</p>"
425+
}
426+
},
427+
"percentPromotedItems": {
428+
"target": "com.amazonaws.personalizeruntime#PercentPromotedItems",
429+
"traits": {
430+
"smithy.api#documentation": "<p>The percentage of recommended items to apply the promotion to.</p>"
431+
}
432+
},
433+
"filterArn": {
434+
"target": "com.amazonaws.personalizeruntime#Arn",
435+
"traits": {
436+
"smithy.api#documentation": "<p>The Amazon Resource Name (ARN) of the filter used by the promotion. This filter defines the criteria for promoted items. For more information, see \n <a href=\"https://docs.aws.amazon.com/personalize/latest/dg/promoting-items.html#promotion-filters\">Promotion filters</a>.</p>"
437+
}
438+
},
439+
"filterValues": {
440+
"target": "com.amazonaws.personalizeruntime#FilterValues",
441+
"traits": {
442+
"smithy.api#documentation": "<p>The values to use when promoting items.\n For each placeholder parameter in your promotion's filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. \n </p>\n <p>For filter expressions that use an <code>INCLUDE</code> element to include items,\n you must provide values for all parameters that are defined in the expression. For\n filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you\n can omit the <code>filter-values</code>. In this case, Amazon Personalize doesn't use that portion of\n the expression to filter recommendations.</p>\n <p>For more information on creating filters, see\n <a href=\"https://docs.aws.amazon.com/personalize/latest/dg/filter.html\">Filtering recommendations and user segments</a>.</p>"
443+
}
444+
}
445+
},
446+
"traits": {
447+
"smithy.api#documentation": "<p>Contains information on a promotion. A promotion defines additional business rules that apply to a configurable subset of recommended items.</p>"
448+
}
449+
},
450+
"com.amazonaws.personalizeruntime#PromotionList": {
451+
"type": "list",
452+
"member": {
453+
"target": "com.amazonaws.personalizeruntime#Promotion"
454+
},
455+
"traits": {
456+
"smithy.api#length": {
457+
"min": 0,
458+
"max": 1
459+
}
460+
}
461+
},
387462
"com.amazonaws.personalizeruntime#RecommendationID": {
388463
"type": "string"
389464
},

0 commit comments

Comments
 (0)