Skip to content

Commit 67d79bf

Browse files
author
awstools
committed
feat(client-personalize): Adding StartRecommender and StopRecommender APIs for Personalize.
1 parent 17ba1fe commit 67d79bf

File tree

9 files changed

+638
-5
lines changed

9 files changed

+638
-5
lines changed

clients/client-personalize/src/Personalize.ts

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,16 @@ import {
253253
ListTagsForResourceCommandInput,
254254
ListTagsForResourceCommandOutput,
255255
} from "./commands/ListTagsForResourceCommand";
256+
import {
257+
StartRecommenderCommand,
258+
StartRecommenderCommandInput,
259+
StartRecommenderCommandOutput,
260+
} from "./commands/StartRecommenderCommand";
261+
import {
262+
StopRecommenderCommand,
263+
StopRecommenderCommandInput,
264+
StopRecommenderCommandOutput,
265+
} from "./commands/StopRecommenderCommand";
256266
import {
257267
StopSolutionVersionCreationCommand,
258268
StopSolutionVersionCreationCommandInput,
@@ -2605,6 +2615,71 @@ export class Personalize extends PersonalizeClient {
26052615
}
26062616
}
26072617

2618+
/**
2619+
* <p>Starts a recommender that is INACTIVE. Starting a recommender does not
2620+
* create any new models, but resumes billing and automatic retraining for the recommender.</p>
2621+
*/
2622+
public startRecommender(
2623+
args: StartRecommenderCommandInput,
2624+
options?: __HttpHandlerOptions
2625+
): Promise<StartRecommenderCommandOutput>;
2626+
public startRecommender(
2627+
args: StartRecommenderCommandInput,
2628+
cb: (err: any, data?: StartRecommenderCommandOutput) => void
2629+
): void;
2630+
public startRecommender(
2631+
args: StartRecommenderCommandInput,
2632+
options: __HttpHandlerOptions,
2633+
cb: (err: any, data?: StartRecommenderCommandOutput) => void
2634+
): void;
2635+
public startRecommender(
2636+
args: StartRecommenderCommandInput,
2637+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StartRecommenderCommandOutput) => void),
2638+
cb?: (err: any, data?: StartRecommenderCommandOutput) => void
2639+
): Promise<StartRecommenderCommandOutput> | void {
2640+
const command = new StartRecommenderCommand(args);
2641+
if (typeof optionsOrCb === "function") {
2642+
this.send(command, optionsOrCb);
2643+
} else if (typeof cb === "function") {
2644+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
2645+
this.send(command, optionsOrCb || {}, cb);
2646+
} else {
2647+
return this.send(command, optionsOrCb);
2648+
}
2649+
}
2650+
2651+
/**
2652+
* <p>Stops a recommender that is ACTIVE. Stopping a recommender halts billing and automatic retraining for the recommender.</p>
2653+
*/
2654+
public stopRecommender(
2655+
args: StopRecommenderCommandInput,
2656+
options?: __HttpHandlerOptions
2657+
): Promise<StopRecommenderCommandOutput>;
2658+
public stopRecommender(
2659+
args: StopRecommenderCommandInput,
2660+
cb: (err: any, data?: StopRecommenderCommandOutput) => void
2661+
): void;
2662+
public stopRecommender(
2663+
args: StopRecommenderCommandInput,
2664+
options: __HttpHandlerOptions,
2665+
cb: (err: any, data?: StopRecommenderCommandOutput) => void
2666+
): void;
2667+
public stopRecommender(
2668+
args: StopRecommenderCommandInput,
2669+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StopRecommenderCommandOutput) => void),
2670+
cb?: (err: any, data?: StopRecommenderCommandOutput) => void
2671+
): Promise<StopRecommenderCommandOutput> | void {
2672+
const command = new StopRecommenderCommand(args);
2673+
if (typeof optionsOrCb === "function") {
2674+
this.send(command, optionsOrCb);
2675+
} else if (typeof cb === "function") {
2676+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
2677+
this.send(command, optionsOrCb || {}, cb);
2678+
} else {
2679+
return this.send(command, optionsOrCb);
2680+
}
2681+
}
2682+
26082683
/**
26092684
* <p>Stops creating a solution version that is in a state of CREATE_PENDING or CREATE IN_PROGRESS.
26102685
* </p>
@@ -2713,10 +2788,13 @@ export class Personalize extends PersonalizeClient {
27132788
* campaign's <code>minProvisionedTPS</code> parameter.</p>
27142789
* <p>To update a campaign, the campaign status must be ACTIVE or CREATE FAILED.
27152790
* Check the campaign status using the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeCampaign.html">DescribeCampaign</a> operation.</p>
2791+
*
27162792
* <note>
2717-
* <p>You must wait until the <code>status</code> of the
2718-
* updated campaign is <code>ACTIVE</code> before asking the campaign for recommendations.</p>
2793+
* <p>You can still get recommendations from a campaign while an update is in progress.
2794+
* The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is <code>Active</code>.
2795+
* </p>
27192796
* </note>
2797+
*
27202798
* <p>For more information on campaigns, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_CreateCampaign.html">CreateCampaign</a>.</p>
27212799
*/
27222800
public updateCampaign(

clients/client-personalize/src/PersonalizeClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ import {
164164
ListTagsForResourceCommandInput,
165165
ListTagsForResourceCommandOutput,
166166
} from "./commands/ListTagsForResourceCommand";
167+
import { StartRecommenderCommandInput, StartRecommenderCommandOutput } from "./commands/StartRecommenderCommand";
168+
import { StopRecommenderCommandInput, StopRecommenderCommandOutput } from "./commands/StopRecommenderCommand";
167169
import {
168170
StopSolutionVersionCreationCommandInput,
169171
StopSolutionVersionCreationCommandOutput,
@@ -228,6 +230,8 @@ export type ServiceInputTypes =
228230
| ListSolutionVersionsCommandInput
229231
| ListSolutionsCommandInput
230232
| ListTagsForResourceCommandInput
233+
| StartRecommenderCommandInput
234+
| StopRecommenderCommandInput
231235
| StopSolutionVersionCreationCommandInput
232236
| TagResourceCommandInput
233237
| UntagResourceCommandInput
@@ -288,6 +292,8 @@ export type ServiceOutputTypes =
288292
| ListSolutionVersionsCommandOutput
289293
| ListSolutionsCommandOutput
290294
| ListTagsForResourceCommandOutput
295+
| StartRecommenderCommandOutput
296+
| StopRecommenderCommandOutput
291297
| StopSolutionVersionCreationCommandOutput
292298
| TagResourceCommandOutput
293299
| UntagResourceCommandOutput
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { StartRecommenderRequest, StartRecommenderResponse } from "../models/models_0";
15+
import { PersonalizeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../PersonalizeClient";
16+
import {
17+
deserializeAws_json1_1StartRecommenderCommand,
18+
serializeAws_json1_1StartRecommenderCommand,
19+
} from "../protocols/Aws_json1_1";
20+
21+
export interface StartRecommenderCommandInput extends StartRecommenderRequest {}
22+
export interface StartRecommenderCommandOutput extends StartRecommenderResponse, __MetadataBearer {}
23+
24+
/**
25+
* <p>Starts a recommender that is INACTIVE. Starting a recommender does not
26+
* create any new models, but resumes billing and automatic retraining for the recommender.</p>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { PersonalizeClient, StartRecommenderCommand } from "@aws-sdk/client-personalize"; // ES Modules import
31+
* // const { PersonalizeClient, StartRecommenderCommand } = require("@aws-sdk/client-personalize"); // CommonJS import
32+
* const client = new PersonalizeClient(config);
33+
* const command = new StartRecommenderCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link StartRecommenderCommandInput} for command's `input` shape.
38+
* @see {@link StartRecommenderCommandOutput} for command's `response` shape.
39+
* @see {@link PersonalizeClientResolvedConfig | config} for PersonalizeClient's `config` shape.
40+
*
41+
*/
42+
export class StartRecommenderCommand extends $Command<
43+
StartRecommenderCommandInput,
44+
StartRecommenderCommandOutput,
45+
PersonalizeClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: StartRecommenderCommandInput) {
51+
// Start section: command_constructor
52+
super();
53+
// End section: command_constructor
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
resolveMiddleware(
60+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
61+
configuration: PersonalizeClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<StartRecommenderCommandInput, StartRecommenderCommandOutput> {
64+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
65+
66+
const stack = clientStack.concat(this.middlewareStack);
67+
68+
const { logger } = configuration;
69+
const clientName = "PersonalizeClient";
70+
const commandName = "StartRecommenderCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: StartRecommenderRequest.filterSensitiveLog,
76+
outputFilterSensitiveLog: StartRecommenderResponse.filterSensitiveLog,
77+
};
78+
const { requestHandler } = configuration;
79+
return stack.resolve(
80+
(request: FinalizeHandlerArguments<any>) =>
81+
requestHandler.handle(request.request as __HttpRequest, options || {}),
82+
handlerExecutionContext
83+
);
84+
}
85+
86+
private serialize(input: StartRecommenderCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_json1_1StartRecommenderCommand(input, context);
88+
}
89+
90+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<StartRecommenderCommandOutput> {
91+
return deserializeAws_json1_1StartRecommenderCommand(output, context);
92+
}
93+
94+
// Start section: command_body_extra
95+
// End section: command_body_extra
96+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { StopRecommenderRequest, StopRecommenderResponse } from "../models/models_0";
15+
import { PersonalizeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../PersonalizeClient";
16+
import {
17+
deserializeAws_json1_1StopRecommenderCommand,
18+
serializeAws_json1_1StopRecommenderCommand,
19+
} from "../protocols/Aws_json1_1";
20+
21+
export interface StopRecommenderCommandInput extends StopRecommenderRequest {}
22+
export interface StopRecommenderCommandOutput extends StopRecommenderResponse, __MetadataBearer {}
23+
24+
/**
25+
* <p>Stops a recommender that is ACTIVE. Stopping a recommender halts billing and automatic retraining for the recommender.</p>
26+
* @example
27+
* Use a bare-bones client and the command you need to make an API call.
28+
* ```javascript
29+
* import { PersonalizeClient, StopRecommenderCommand } from "@aws-sdk/client-personalize"; // ES Modules import
30+
* // const { PersonalizeClient, StopRecommenderCommand } = require("@aws-sdk/client-personalize"); // CommonJS import
31+
* const client = new PersonalizeClient(config);
32+
* const command = new StopRecommenderCommand(input);
33+
* const response = await client.send(command);
34+
* ```
35+
*
36+
* @see {@link StopRecommenderCommandInput} for command's `input` shape.
37+
* @see {@link StopRecommenderCommandOutput} for command's `response` shape.
38+
* @see {@link PersonalizeClientResolvedConfig | config} for PersonalizeClient's `config` shape.
39+
*
40+
*/
41+
export class StopRecommenderCommand extends $Command<
42+
StopRecommenderCommandInput,
43+
StopRecommenderCommandOutput,
44+
PersonalizeClientResolvedConfig
45+
> {
46+
// Start section: command_properties
47+
// End section: command_properties
48+
49+
constructor(readonly input: StopRecommenderCommandInput) {
50+
// Start section: command_constructor
51+
super();
52+
// End section: command_constructor
53+
}
54+
55+
/**
56+
* @internal
57+
*/
58+
resolveMiddleware(
59+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
60+
configuration: PersonalizeClientResolvedConfig,
61+
options?: __HttpHandlerOptions
62+
): Handler<StopRecommenderCommandInput, StopRecommenderCommandOutput> {
63+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
64+
65+
const stack = clientStack.concat(this.middlewareStack);
66+
67+
const { logger } = configuration;
68+
const clientName = "PersonalizeClient";
69+
const commandName = "StopRecommenderCommand";
70+
const handlerExecutionContext: HandlerExecutionContext = {
71+
logger,
72+
clientName,
73+
commandName,
74+
inputFilterSensitiveLog: StopRecommenderRequest.filterSensitiveLog,
75+
outputFilterSensitiveLog: StopRecommenderResponse.filterSensitiveLog,
76+
};
77+
const { requestHandler } = configuration;
78+
return stack.resolve(
79+
(request: FinalizeHandlerArguments<any>) =>
80+
requestHandler.handle(request.request as __HttpRequest, options || {}),
81+
handlerExecutionContext
82+
);
83+
}
84+
85+
private serialize(input: StopRecommenderCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
86+
return serializeAws_json1_1StopRecommenderCommand(input, context);
87+
}
88+
89+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<StopRecommenderCommandOutput> {
90+
return deserializeAws_json1_1StopRecommenderCommand(output, context);
91+
}
92+
93+
// Start section: command_body_extra
94+
// End section: command_body_extra
95+
}

clients/client-personalize/src/commands/UpdateCampaignCommand.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ export interface UpdateCampaignCommandOutput extends UpdateCampaignResponse, __M
2626
* campaign's <code>minProvisionedTPS</code> parameter.</p>
2727
* <p>To update a campaign, the campaign status must be ACTIVE or CREATE FAILED.
2828
* Check the campaign status using the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeCampaign.html">DescribeCampaign</a> operation.</p>
29+
*
2930
* <note>
30-
* <p>You must wait until the <code>status</code> of the
31-
* updated campaign is <code>ACTIVE</code> before asking the campaign for recommendations.</p>
31+
* <p>You can still get recommendations from a campaign while an update is in progress.
32+
* The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is <code>Active</code>.
33+
* </p>
3234
* </note>
35+
*
3336
* <p>For more information on campaigns, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_CreateCampaign.html">CreateCampaign</a>.</p>
3437
* @example
3538
* Use a bare-bones client and the command you need to make an API call.

clients/client-personalize/src/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export * from "./ListSchemasCommand";
5151
export * from "./ListSolutionVersionsCommand";
5252
export * from "./ListSolutionsCommand";
5353
export * from "./ListTagsForResourceCommand";
54+
export * from "./StartRecommenderCommand";
55+
export * from "./StopRecommenderCommand";
5456
export * from "./StopSolutionVersionCreationCommand";
5557
export * from "./TagResourceCommand";
5658
export * from "./UntagResourceCommand";

0 commit comments

Comments
 (0)