Skip to content

Commit 687e16d

Browse files
author
awstools
committed
feat(client-personalize-runtime): Enables metadata in recommendations and next best action recommendations
1 parent c3cf9f2 commit 687e16d

File tree

10 files changed

+730
-47
lines changed

10 files changed

+730
-47
lines changed

clients/client-personalize-runtime/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ see LICENSE for more information.
203203

204204
## Client Commands (Operations List)
205205

206+
<details>
207+
<summary>
208+
GetActionRecommendations
209+
</summary>
210+
211+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/personalize-runtime/command/GetActionRecommendationsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-personalize-runtime/Interface/GetActionRecommendationsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-personalize-runtime/Interface/GetActionRecommendationsCommandOutput/)
212+
213+
</details>
206214
<details>
207215
<summary>
208216
GetPersonalizedRanking

clients/client-personalize-runtime/src/PersonalizeRuntime.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
import { createAggregatedClient } from "@smithy/smithy-client";
33
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
44

5+
import {
6+
GetActionRecommendationsCommand,
7+
GetActionRecommendationsCommandInput,
8+
GetActionRecommendationsCommandOutput,
9+
} from "./commands/GetActionRecommendationsCommand";
510
import {
611
GetPersonalizedRankingCommand,
712
GetPersonalizedRankingCommandInput,
@@ -15,11 +20,29 @@ import {
1520
import { PersonalizeRuntimeClient, PersonalizeRuntimeClientConfig } from "./PersonalizeRuntimeClient";
1621

1722
const commands = {
23+
GetActionRecommendationsCommand,
1824
GetPersonalizedRankingCommand,
1925
GetRecommendationsCommand,
2026
};
2127

2228
export interface PersonalizeRuntime {
29+
/**
30+
* @see {@link GetActionRecommendationsCommand}
31+
*/
32+
getActionRecommendations(
33+
args: GetActionRecommendationsCommandInput,
34+
options?: __HttpHandlerOptions
35+
): Promise<GetActionRecommendationsCommandOutput>;
36+
getActionRecommendations(
37+
args: GetActionRecommendationsCommandInput,
38+
cb: (err: any, data?: GetActionRecommendationsCommandOutput) => void
39+
): void;
40+
getActionRecommendations(
41+
args: GetActionRecommendationsCommandInput,
42+
options: __HttpHandlerOptions,
43+
cb: (err: any, data?: GetActionRecommendationsCommandOutput) => void
44+
): void;
45+
2346
/**
2447
* @see {@link GetPersonalizedRankingCommand}
2548
*/

clients/client-personalize-runtime/src/PersonalizeRuntimeClient.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ import {
5050
UserAgent as __UserAgent,
5151
} from "@smithy/types";
5252

53+
import {
54+
GetActionRecommendationsCommandInput,
55+
GetActionRecommendationsCommandOutput,
56+
} from "./commands/GetActionRecommendationsCommand";
5357
import {
5458
GetPersonalizedRankingCommandInput,
5559
GetPersonalizedRankingCommandOutput,
@@ -69,12 +73,18 @@ export { __Client };
6973
/**
7074
* @public
7175
*/
72-
export type ServiceInputTypes = GetPersonalizedRankingCommandInput | GetRecommendationsCommandInput;
76+
export type ServiceInputTypes =
77+
| GetActionRecommendationsCommandInput
78+
| GetPersonalizedRankingCommandInput
79+
| GetRecommendationsCommandInput;
7380

7481
/**
7582
* @public
7683
*/
77-
export type ServiceOutputTypes = GetPersonalizedRankingCommandOutput | GetRecommendationsCommandOutput;
84+
export type ServiceOutputTypes =
85+
| GetActionRecommendationsCommandOutput
86+
| GetPersonalizedRankingCommandOutput
87+
| GetRecommendationsCommandOutput;
7888

7989
/**
8090
* @public
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// smithy-typescript generated code
2+
import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
5+
import { Command as $Command } from "@smithy/smithy-client";
6+
import {
7+
FinalizeHandlerArguments,
8+
Handler,
9+
HandlerExecutionContext,
10+
HttpHandlerOptions as __HttpHandlerOptions,
11+
MetadataBearer as __MetadataBearer,
12+
MiddlewareStack,
13+
SerdeContext as __SerdeContext,
14+
SMITHY_CONTEXT_KEY,
15+
} from "@smithy/types";
16+
17+
import {
18+
GetActionRecommendationsRequest,
19+
GetActionRecommendationsRequestFilterSensitiveLog,
20+
GetActionRecommendationsResponse,
21+
} from "../models/models_0";
22+
import {
23+
PersonalizeRuntimeClientResolvedConfig,
24+
ServiceInputTypes,
25+
ServiceOutputTypes,
26+
} from "../PersonalizeRuntimeClient";
27+
import { de_GetActionRecommendationsCommand, se_GetActionRecommendationsCommand } from "../protocols/Aws_restJson1";
28+
29+
/**
30+
* @public
31+
*/
32+
export { __MetadataBearer, $Command };
33+
/**
34+
* @public
35+
*
36+
* The input for {@link GetActionRecommendationsCommand}.
37+
*/
38+
export interface GetActionRecommendationsCommandInput extends GetActionRecommendationsRequest {}
39+
/**
40+
* @public
41+
*
42+
* The output of {@link GetActionRecommendationsCommand}.
43+
*/
44+
export interface GetActionRecommendationsCommandOutput extends GetActionRecommendationsResponse, __MetadataBearer {}
45+
46+
/**
47+
* @public
48+
* <p>Returns a list of recommended actions in sorted in descending order by prediction score.
49+
* Use the <code>GetActionRecommendations</code> API if you have a custom
50+
* campaign that deploys a solution version trained with a PERSONALIZED_ACTIONS recipe.
51+
* </p>
52+
* <p>For more information about PERSONALIZED_ACTIONS recipes, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/nexts-best-action-recipes.html">PERSONALIZED_ACTIONS recipes</a>.
53+
* For more information about getting action recommendations, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/get-action-recommendations.html">Getting action recommendations</a>.</p>
54+
* @example
55+
* Use a bare-bones client and the command you need to make an API call.
56+
* ```javascript
57+
* import { PersonalizeRuntimeClient, GetActionRecommendationsCommand } from "@aws-sdk/client-personalize-runtime"; // ES Modules import
58+
* // const { PersonalizeRuntimeClient, GetActionRecommendationsCommand } = require("@aws-sdk/client-personalize-runtime"); // CommonJS import
59+
* const client = new PersonalizeRuntimeClient(config);
60+
* const input = { // GetActionRecommendationsRequest
61+
* campaignArn: "STRING_VALUE",
62+
* userId: "STRING_VALUE",
63+
* numResults: Number("int"),
64+
* filterArn: "STRING_VALUE",
65+
* filterValues: { // FilterValues
66+
* "<keys>": "STRING_VALUE",
67+
* },
68+
* };
69+
* const command = new GetActionRecommendationsCommand(input);
70+
* const response = await client.send(command);
71+
* // { // GetActionRecommendationsResponse
72+
* // actionList: [ // ActionList
73+
* // { // PredictedAction
74+
* // actionId: "STRING_VALUE",
75+
* // score: Number("double"),
76+
* // },
77+
* // ],
78+
* // recommendationId: "STRING_VALUE",
79+
* // };
80+
*
81+
* ```
82+
*
83+
* @param GetActionRecommendationsCommandInput - {@link GetActionRecommendationsCommandInput}
84+
* @returns {@link GetActionRecommendationsCommandOutput}
85+
* @see {@link GetActionRecommendationsCommandInput} for command's `input` shape.
86+
* @see {@link GetActionRecommendationsCommandOutput} for command's `response` shape.
87+
* @see {@link PersonalizeRuntimeClientResolvedConfig | config} for PersonalizeRuntimeClient's `config` shape.
88+
*
89+
* @throws {@link InvalidInputException} (client fault)
90+
* <p>Provide a valid value for the field or parameter.</p>
91+
*
92+
* @throws {@link ResourceNotFoundException} (client fault)
93+
* <p>The specified resource does not exist.</p>
94+
*
95+
* @throws {@link PersonalizeRuntimeServiceException}
96+
* <p>Base exception class for all service exceptions from PersonalizeRuntime service.</p>
97+
*
98+
*/
99+
export class GetActionRecommendationsCommand extends $Command<
100+
GetActionRecommendationsCommandInput,
101+
GetActionRecommendationsCommandOutput,
102+
PersonalizeRuntimeClientResolvedConfig
103+
> {
104+
public static getEndpointParameterInstructions(): EndpointParameterInstructions {
105+
return {
106+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
107+
Endpoint: { type: "builtInParams", name: "endpoint" },
108+
Region: { type: "builtInParams", name: "region" },
109+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
110+
};
111+
}
112+
113+
/**
114+
* @public
115+
*/
116+
constructor(readonly input: GetActionRecommendationsCommandInput) {
117+
super();
118+
}
119+
120+
/**
121+
* @internal
122+
*/
123+
resolveMiddleware(
124+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
125+
configuration: PersonalizeRuntimeClientResolvedConfig,
126+
options?: __HttpHandlerOptions
127+
): Handler<GetActionRecommendationsCommandInput, GetActionRecommendationsCommandOutput> {
128+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
129+
this.middlewareStack.use(
130+
getEndpointPlugin(configuration, GetActionRecommendationsCommand.getEndpointParameterInstructions())
131+
);
132+
133+
const stack = clientStack.concat(this.middlewareStack);
134+
135+
const { logger } = configuration;
136+
const clientName = "PersonalizeRuntimeClient";
137+
const commandName = "GetActionRecommendationsCommand";
138+
const handlerExecutionContext: HandlerExecutionContext = {
139+
logger,
140+
clientName,
141+
commandName,
142+
inputFilterSensitiveLog: GetActionRecommendationsRequestFilterSensitiveLog,
143+
outputFilterSensitiveLog: (_: any) => _,
144+
[SMITHY_CONTEXT_KEY]: {
145+
service: "AmazonPersonalizeRuntime",
146+
operation: "GetActionRecommendations",
147+
},
148+
};
149+
const { requestHandler } = configuration;
150+
return stack.resolve(
151+
(request: FinalizeHandlerArguments<any>) =>
152+
requestHandler.handle(request.request as __HttpRequest, options || {}),
153+
handlerExecutionContext
154+
);
155+
}
156+
157+
/**
158+
* @internal
159+
*/
160+
private serialize(input: GetActionRecommendationsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
161+
return se_GetActionRecommendationsCommand(input, context);
162+
}
163+
164+
/**
165+
* @internal
166+
*/
167+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetActionRecommendationsCommandOutput> {
168+
return de_GetActionRecommendationsCommand(output, context);
169+
}
170+
}

clients/client-personalize-runtime/src/commands/GetPersonalizedRankingCommand.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export interface GetPersonalizedRankingCommandOutput extends GetPersonalizedRank
7070
* filterValues: { // FilterValues
7171
* "<keys>": "STRING_VALUE",
7272
* },
73+
* metadataColumns: { // MetadataColumns
74+
* "<keys>": [ // ColumnNamesList
75+
* "STRING_VALUE",
76+
* ],
77+
* },
7378
* };
7479
* const command = new GetPersonalizedRankingCommand(input);
7580
* const response = await client.send(command);
@@ -79,6 +84,9 @@ export interface GetPersonalizedRankingCommandOutput extends GetPersonalizedRank
7984
* // itemId: "STRING_VALUE",
8085
* // score: Number("double"),
8186
* // promotionName: "STRING_VALUE",
87+
* // metadata: { // Metadata
88+
* // "<keys>": "STRING_VALUE",
89+
* // },
8290
* // },
8391
* // ],
8492
* // recommendationId: "STRING_VALUE",

clients/client-personalize-runtime/src/commands/GetRecommendationsCommand.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export interface GetRecommendationsCommandOutput extends GetRecommendationsRespo
9292
* },
9393
* },
9494
* ],
95+
* metadataColumns: { // MetadataColumns
96+
* "<keys>": [ // ColumnNamesList
97+
* "STRING_VALUE",
98+
* ],
99+
* },
95100
* };
96101
* const command = new GetRecommendationsCommand(input);
97102
* const response = await client.send(command);
@@ -101,6 +106,9 @@ export interface GetRecommendationsCommandOutput extends GetRecommendationsRespo
101106
* // itemId: "STRING_VALUE",
102107
* // score: Number("double"),
103108
* // promotionName: "STRING_VALUE",
109+
* // metadata: { // Metadata
110+
* // "<keys>": "STRING_VALUE",
111+
* // },
104112
* // },
105113
* // ],
106114
* // recommendationId: "STRING_VALUE",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// smithy-typescript generated code
2+
export * from "./GetActionRecommendationsCommand";
23
export * from "./GetPersonalizedRankingCommand";
34
export * from "./GetRecommendationsCommand";

0 commit comments

Comments
 (0)