Skip to content

Commit

Permalink
feat(client-personalize): Adding StartRecommender and StopRecommender…
Browse files Browse the repository at this point in the history
… APIs for Personalize.
  • Loading branch information
awstools committed Apr 19, 2022
1 parent 17ba1fe commit 67d79bf
Show file tree
Hide file tree
Showing 9 changed files with 638 additions and 5 deletions.
82 changes: 80 additions & 2 deletions clients/client-personalize/src/Personalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import {
StartRecommenderCommand,
StartRecommenderCommandInput,
StartRecommenderCommandOutput,
} from "./commands/StartRecommenderCommand";
import {
StopRecommenderCommand,
StopRecommenderCommandInput,
StopRecommenderCommandOutput,
} from "./commands/StopRecommenderCommand";
import {
StopSolutionVersionCreationCommand,
StopSolutionVersionCreationCommandInput,
Expand Down Expand Up @@ -2605,6 +2615,71 @@ export class Personalize extends PersonalizeClient {
}
}

/**
* <p>Starts a recommender that is INACTIVE. Starting a recommender does not
* create any new models, but resumes billing and automatic retraining for the recommender.</p>
*/
public startRecommender(
args: StartRecommenderCommandInput,
options?: __HttpHandlerOptions
): Promise<StartRecommenderCommandOutput>;
public startRecommender(
args: StartRecommenderCommandInput,
cb: (err: any, data?: StartRecommenderCommandOutput) => void
): void;
public startRecommender(
args: StartRecommenderCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: StartRecommenderCommandOutput) => void
): void;
public startRecommender(
args: StartRecommenderCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StartRecommenderCommandOutput) => void),
cb?: (err: any, data?: StartRecommenderCommandOutput) => void
): Promise<StartRecommenderCommandOutput> | void {
const command = new StartRecommenderCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Stops a recommender that is ACTIVE. Stopping a recommender halts billing and automatic retraining for the recommender.</p>
*/
public stopRecommender(
args: StopRecommenderCommandInput,
options?: __HttpHandlerOptions
): Promise<StopRecommenderCommandOutput>;
public stopRecommender(
args: StopRecommenderCommandInput,
cb: (err: any, data?: StopRecommenderCommandOutput) => void
): void;
public stopRecommender(
args: StopRecommenderCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: StopRecommenderCommandOutput) => void
): void;
public stopRecommender(
args: StopRecommenderCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StopRecommenderCommandOutput) => void),
cb?: (err: any, data?: StopRecommenderCommandOutput) => void
): Promise<StopRecommenderCommandOutput> | void {
const command = new StopRecommenderCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Stops creating a solution version that is in a state of CREATE_PENDING or CREATE IN_PROGRESS.
* </p>
Expand Down Expand Up @@ -2713,10 +2788,13 @@ export class Personalize extends PersonalizeClient {
* campaign's <code>minProvisionedTPS</code> parameter.</p>
* <p>To update a campaign, the campaign status must be ACTIVE or CREATE FAILED.
* Check the campaign status using the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeCampaign.html">DescribeCampaign</a> operation.</p>
*
* <note>
* <p>You must wait until the <code>status</code> of the
* updated campaign is <code>ACTIVE</code> before asking the campaign for recommendations.</p>
* <p>You can still get recommendations from a campaign while an update is in progress.
* The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is <code>Active</code>.
* </p>
* </note>
*
* <p>For more information on campaigns, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_CreateCampaign.html">CreateCampaign</a>.</p>
*/
public updateCampaign(
Expand Down
6 changes: 6 additions & 0 deletions clients/client-personalize/src/PersonalizeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import { StartRecommenderCommandInput, StartRecommenderCommandOutput } from "./commands/StartRecommenderCommand";
import { StopRecommenderCommandInput, StopRecommenderCommandOutput } from "./commands/StopRecommenderCommand";
import {
StopSolutionVersionCreationCommandInput,
StopSolutionVersionCreationCommandOutput,
Expand Down Expand Up @@ -228,6 +230,8 @@ export type ServiceInputTypes =
| ListSolutionVersionsCommandInput
| ListSolutionsCommandInput
| ListTagsForResourceCommandInput
| StartRecommenderCommandInput
| StopRecommenderCommandInput
| StopSolutionVersionCreationCommandInput
| TagResourceCommandInput
| UntagResourceCommandInput
Expand Down Expand Up @@ -288,6 +292,8 @@ export type ServiceOutputTypes =
| ListSolutionVersionsCommandOutput
| ListSolutionsCommandOutput
| ListTagsForResourceCommandOutput
| StartRecommenderCommandOutput
| StopRecommenderCommandOutput
| StopSolutionVersionCreationCommandOutput
| TagResourceCommandOutput
| UntagResourceCommandOutput
Expand Down
96 changes: 96 additions & 0 deletions clients/client-personalize/src/commands/StartRecommenderCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { StartRecommenderRequest, StartRecommenderResponse } from "../models/models_0";
import { PersonalizeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../PersonalizeClient";
import {
deserializeAws_json1_1StartRecommenderCommand,
serializeAws_json1_1StartRecommenderCommand,
} from "../protocols/Aws_json1_1";

export interface StartRecommenderCommandInput extends StartRecommenderRequest {}
export interface StartRecommenderCommandOutput extends StartRecommenderResponse, __MetadataBearer {}

/**
* <p>Starts a recommender that is INACTIVE. Starting a recommender does not
* create any new models, but resumes billing and automatic retraining for the recommender.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { PersonalizeClient, StartRecommenderCommand } from "@aws-sdk/client-personalize"; // ES Modules import
* // const { PersonalizeClient, StartRecommenderCommand } = require("@aws-sdk/client-personalize"); // CommonJS import
* const client = new PersonalizeClient(config);
* const command = new StartRecommenderCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link StartRecommenderCommandInput} for command's `input` shape.
* @see {@link StartRecommenderCommandOutput} for command's `response` shape.
* @see {@link PersonalizeClientResolvedConfig | config} for PersonalizeClient's `config` shape.
*
*/
export class StartRecommenderCommand extends $Command<
StartRecommenderCommandInput,
StartRecommenderCommandOutput,
PersonalizeClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: StartRecommenderCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: PersonalizeClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<StartRecommenderCommandInput, StartRecommenderCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "PersonalizeClient";
const commandName = "StartRecommenderCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: StartRecommenderRequest.filterSensitiveLog,
outputFilterSensitiveLog: StartRecommenderResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: StartRecommenderCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1StartRecommenderCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<StartRecommenderCommandOutput> {
return deserializeAws_json1_1StartRecommenderCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
95 changes: 95 additions & 0 deletions clients/client-personalize/src/commands/StopRecommenderCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { StopRecommenderRequest, StopRecommenderResponse } from "../models/models_0";
import { PersonalizeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../PersonalizeClient";
import {
deserializeAws_json1_1StopRecommenderCommand,
serializeAws_json1_1StopRecommenderCommand,
} from "../protocols/Aws_json1_1";

export interface StopRecommenderCommandInput extends StopRecommenderRequest {}
export interface StopRecommenderCommandOutput extends StopRecommenderResponse, __MetadataBearer {}

/**
* <p>Stops a recommender that is ACTIVE. Stopping a recommender halts billing and automatic retraining for the recommender.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { PersonalizeClient, StopRecommenderCommand } from "@aws-sdk/client-personalize"; // ES Modules import
* // const { PersonalizeClient, StopRecommenderCommand } = require("@aws-sdk/client-personalize"); // CommonJS import
* const client = new PersonalizeClient(config);
* const command = new StopRecommenderCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link StopRecommenderCommandInput} for command's `input` shape.
* @see {@link StopRecommenderCommandOutput} for command's `response` shape.
* @see {@link PersonalizeClientResolvedConfig | config} for PersonalizeClient's `config` shape.
*
*/
export class StopRecommenderCommand extends $Command<
StopRecommenderCommandInput,
StopRecommenderCommandOutput,
PersonalizeClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: StopRecommenderCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: PersonalizeClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<StopRecommenderCommandInput, StopRecommenderCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "PersonalizeClient";
const commandName = "StopRecommenderCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: StopRecommenderRequest.filterSensitiveLog,
outputFilterSensitiveLog: StopRecommenderResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: StopRecommenderCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1StopRecommenderCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<StopRecommenderCommandOutput> {
return deserializeAws_json1_1StopRecommenderCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ export interface UpdateCampaignCommandOutput extends UpdateCampaignResponse, __M
* campaign's <code>minProvisionedTPS</code> parameter.</p>
* <p>To update a campaign, the campaign status must be ACTIVE or CREATE FAILED.
* Check the campaign status using the <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_DescribeCampaign.html">DescribeCampaign</a> operation.</p>
*
* <note>
* <p>You must wait until the <code>status</code> of the
* updated campaign is <code>ACTIVE</code> before asking the campaign for recommendations.</p>
* <p>You can still get recommendations from a campaign while an update is in progress.
* The campaign will use the previous solution version and campaign configuration to generate recommendations until the latest campaign update status is <code>Active</code>.
* </p>
* </note>
*
* <p>For more information on campaigns, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/API_CreateCampaign.html">CreateCampaign</a>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
2 changes: 2 additions & 0 deletions clients/client-personalize/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export * from "./ListSchemasCommand";
export * from "./ListSolutionVersionsCommand";
export * from "./ListSolutionsCommand";
export * from "./ListTagsForResourceCommand";
export * from "./StartRecommenderCommand";
export * from "./StopRecommenderCommand";
export * from "./StopSolutionVersionCreationCommand";
export * from "./TagResourceCommand";
export * from "./UntagResourceCommand";
Expand Down
Loading

0 comments on commit 67d79bf

Please sign in to comment.