Skip to content

Commit

Permalink
feat(client-lex-models-v2): This release introduces a new feature to …
Browse files Browse the repository at this point in the history
…stop a running BotRecommendation Job for Automated Chatbot Designer.
  • Loading branch information
awstools committed Aug 22, 2022
1 parent 356d5df commit 48b347b
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 105 deletions.
37 changes: 37 additions & 0 deletions clients/client-lex-models-v2/src/LexModelsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ import {
StartBotRecommendationCommandOutput,
} from "./commands/StartBotRecommendationCommand";
import { StartImportCommand, StartImportCommandInput, StartImportCommandOutput } from "./commands/StartImportCommand";
import {
StopBotRecommendationCommand,
StopBotRecommendationCommandInput,
StopBotRecommendationCommandOutput,
} from "./commands/StopBotRecommendationCommand";
import { TagResourceCommand, TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import {
UntagResourceCommand,
Expand Down Expand Up @@ -2117,6 +2122,38 @@ export class LexModelsV2 extends LexModelsV2Client {
}
}

/**
* <p>Stop an already running Bot Recommendation request.</p>
*/
public stopBotRecommendation(
args: StopBotRecommendationCommandInput,
options?: __HttpHandlerOptions
): Promise<StopBotRecommendationCommandOutput>;
public stopBotRecommendation(
args: StopBotRecommendationCommandInput,
cb: (err: any, data?: StopBotRecommendationCommandOutput) => void
): void;
public stopBotRecommendation(
args: StopBotRecommendationCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: StopBotRecommendationCommandOutput) => void
): void;
public stopBotRecommendation(
args: StopBotRecommendationCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StopBotRecommendationCommandOutput) => void),
cb?: (err: any, data?: StopBotRecommendationCommandOutput) => void
): Promise<StopBotRecommendationCommandOutput> | void {
const command = new StopBotRecommendationCommand(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>Adds the specified tags to the specified resource. If a tag key
* already exists, the existing value is replaced with the new
Expand Down
6 changes: 6 additions & 0 deletions clients/client-lex-models-v2/src/LexModelsV2Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ import {
StartBotRecommendationCommandOutput,
} from "./commands/StartBotRecommendationCommand";
import { StartImportCommandInput, StartImportCommandOutput } from "./commands/StartImportCommand";
import {
StopBotRecommendationCommandInput,
StopBotRecommendationCommandOutput,
} from "./commands/StopBotRecommendationCommand";
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
import { UpdateBotAliasCommandInput, UpdateBotAliasCommandOutput } from "./commands/UpdateBotAliasCommand";
Expand Down Expand Up @@ -228,6 +232,7 @@ export type ServiceInputTypes =
| SearchAssociatedTranscriptsCommandInput
| StartBotRecommendationCommandInput
| StartImportCommandInput
| StopBotRecommendationCommandInput
| TagResourceCommandInput
| UntagResourceCommandInput
| UpdateBotAliasCommandInput
Expand Down Expand Up @@ -296,6 +301,7 @@ export type ServiceOutputTypes =
| SearchAssociatedTranscriptsCommandOutput
| StartBotRecommendationCommandOutput
| StartImportCommandOutput
| StopBotRecommendationCommandOutput
| TagResourceCommandOutput
| UntagResourceCommandOutput
| UpdateBotAliasCommandOutput
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// smithy-typescript generated code
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 { LexModelsV2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../LexModelsV2Client";
import {
StopBotRecommendationRequest,
StopBotRecommendationRequestFilterSensitiveLog,
StopBotRecommendationResponse,
StopBotRecommendationResponseFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_restJson1StopBotRecommendationCommand,
serializeAws_restJson1StopBotRecommendationCommand,
} from "../protocols/Aws_restJson1";

export interface StopBotRecommendationCommandInput extends StopBotRecommendationRequest {}
export interface StopBotRecommendationCommandOutput extends StopBotRecommendationResponse, __MetadataBearer {}

/**
* <p>Stop an already running Bot Recommendation request.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { LexModelsV2Client, StopBotRecommendationCommand } from "@aws-sdk/client-lex-models-v2"; // ES Modules import
* // const { LexModelsV2Client, StopBotRecommendationCommand } = require("@aws-sdk/client-lex-models-v2"); // CommonJS import
* const client = new LexModelsV2Client(config);
* const command = new StopBotRecommendationCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link StopBotRecommendationCommandInput} for command's `input` shape.
* @see {@link StopBotRecommendationCommandOutput} for command's `response` shape.
* @see {@link LexModelsV2ClientResolvedConfig | config} for LexModelsV2Client's `config` shape.
*
*/
export class StopBotRecommendationCommand extends $Command<
StopBotRecommendationCommandInput,
StopBotRecommendationCommandOutput,
LexModelsV2ClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

const { logger } = configuration;
const clientName = "LexModelsV2Client";
const commandName = "StopBotRecommendationCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: StopBotRecommendationRequestFilterSensitiveLog,
outputFilterSensitiveLog: StopBotRecommendationResponseFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-lex-models-v2/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export * from "./ListTagsForResourceCommand";
export * from "./SearchAssociatedTranscriptsCommand";
export * from "./StartBotRecommendationCommand";
export * from "./StartImportCommand";
export * from "./StopBotRecommendationCommand";
export * from "./TagResourceCommand";
export * from "./UntagResourceCommand";
export * from "./UpdateBotAliasCommand";
Expand Down
177 changes: 77 additions & 100 deletions clients/client-lex-models-v2/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ export enum BotRecommendationStatus {
Downloading = "Downloading",
Failed = "Failed",
Processing = "Processing",
Stopped = "Stopped",
Stopping = "Stopping",
Updating = "Updating",
}

Expand Down Expand Up @@ -6182,6 +6184,67 @@ export interface StartImportResponse {
creationDateTime?: Date;
}

export interface StopBotRecommendationRequest {
/**
* <p>The unique identifier of the bot containing the bot
* recommendation to be stopped.</p>
*/
botId: string | undefined;

/**
* <p>The version of the bot containing the bot recommendation.</p>
*/
botVersion: string | undefined;

/**
* <p>The identifier of the language and locale of the bot recommendation
* to stop. The string must match one of the supported locales. For more
* information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html">Supported languages</a>
* </p>
*/
localeId: string | undefined;

/**
* <p>The unique identifier of the bot recommendation to be
* stopped.</p>
*/
botRecommendationId: string | undefined;
}

export interface StopBotRecommendationResponse {
/**
* <p>The unique identifier of the bot containing the bot recommendation that
* is being stopped.</p>
*/
botId?: string;

/**
* <p>The version of the bot containing the recommendation that is being
* stopped.</p>
*/
botVersion?: string;

/**
* <p>The identifier of the language and locale of the bot response
* to stop. The string must match one of the supported locales. For more
* information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html">Supported languages</a>
* </p>
*/
localeId?: string;

/**
* <p>The status of the bot recommendation. If the status is Failed,
* then the reasons for the failure are listed in the failureReasons field.</p>
*/
botRecommendationStatus?: BotRecommendationStatus | string;

/**
* <p>The unique identifier of the bot recommendation that is being
* stopped.</p>
*/
botRecommendationId?: string;
}

export interface TagResourceRequest {
/**
* <p>The Amazon Resource Name (ARN) of the bot, bot alias, or bot channel
Expand Down Expand Up @@ -7202,92 +7265,6 @@ export interface FulfillmentCodeHookSettings {
active?: boolean;
}

/**
* <p>Configuration setting for a response sent to the user before Amazon Lex starts eliciting slots.</p>
*/
export interface InitialResponseSetting {
/**
* <p>Specifies a list of message groups that Amazon Lex uses to respond the
* user input.</p>
*/
initialResponse?: ResponseSpecification;

/**
* <p>The next step in the conversation.</p>
*/
nextStep?: DialogState;

/**
* <p>Provides a list of conditional branches. Branches are evaluated in
* the order that they are entered in the list. The first branch with a
* condition that evaluates to true is executed. The last branch in the
* list is the default branch. The default branch should not have any condition
* expression. The default branch is executed if no other branch has a
* matching condition.</p>
*/
conditional?: ConditionalSpecification;

/**
* <p> Settings that specify the dialog code hook that is
* called by Amazon Lex at a step of the conversation. </p>
*/
codeHook?: DialogCodeHookInvocationSetting;
}

/**
* <p>Settings used when Amazon Lex successfully captures a slot
* value from a user.</p>
*/
export interface SlotCaptureSetting {
/**
* <p>Specifies a list of message groups that Amazon Lex uses to respond the
* user input.</p>
*/
captureResponse?: ResponseSpecification;

/**
* <p>Specifies the next step that the bot runs when the slot value is
* captured before the code hook times out.</p>
*/
captureNextStep?: DialogState;

/**
* <p>A list of conditional branches to evaluate after the slot value is
* captured.</p>
*/
captureConditional?: ConditionalSpecification;

/**
* <p>Specifies a list of message groups that Amazon Lex uses to respond the
* user input.</p>
*/
failureResponse?: ResponseSpecification;

/**
* <p>Specifies the next step that the bot runs when the slot value code
* is not recognized.</p>
*/
failureNextStep?: DialogState;

/**
* <p>A list of conditional branches to evaluate when the slot value isn't
* captured.</p>
*/
failureConditional?: ConditionalSpecification;

/**
* <p>Code hook called after Amazon Lex successfully captures a
* slot value.</p>
*/
codeHook?: DialogCodeHookInvocationSetting;

/**
* <p>Code hook called when Amazon Lex doesn't capture a slot
* value.</p>
*/
elicitationCodeHook?: ElicitationCodeHookInvocationSetting;
}

/**
* @internal
*/
Expand Down Expand Up @@ -8789,6 +8766,20 @@ export const StartImportResponseFilterSensitiveLog = (obj: StartImportResponse):
...obj,
});

/**
* @internal
*/
export const StopBotRecommendationRequestFilterSensitiveLog = (obj: StopBotRecommendationRequest): any => ({
...obj,
});

/**
* @internal
*/
export const StopBotRecommendationResponseFilterSensitiveLog = (obj: StopBotRecommendationResponse): any => ({
...obj,
});

/**
* @internal
*/
Expand Down Expand Up @@ -8996,17 +8987,3 @@ export const DialogCodeHookInvocationSettingFilterSensitiveLog = (obj: DialogCod
export const FulfillmentCodeHookSettingsFilterSensitiveLog = (obj: FulfillmentCodeHookSettings): any => ({
...obj,
});

/**
* @internal
*/
export const InitialResponseSettingFilterSensitiveLog = (obj: InitialResponseSetting): any => ({
...obj,
});

/**
* @internal
*/
export const SlotCaptureSettingFilterSensitiveLog = (obj: SlotCaptureSetting): any => ({
...obj,
});
Loading

0 comments on commit 48b347b

Please sign in to comment.