Skip to content

Commit

Permalink
feat(client-cloudtrail): This release adds a new API GenerateQuery th…
Browse files Browse the repository at this point in the history
…at generates a query from a natural language prompt about the event data in your event data store. This operation uses generative artificial intelligence (generative AI) to produce a ready-to-use SQL query from the prompt.
  • Loading branch information
awstools committed Nov 13, 2024
1 parent 8ee2e53 commit 93b16b2
Show file tree
Hide file tree
Showing 10 changed files with 554 additions and 389 deletions.
8 changes: 8 additions & 0 deletions clients/client-cloudtrail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ EnableFederation

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudtrail/command/EnableFederationCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudtrail/Interface/EnableFederationCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudtrail/Interface/EnableFederationCommandOutput/)

</details>
<details>
<summary>
GenerateQuery
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudtrail/command/GenerateQueryCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudtrail/Interface/GenerateQueryCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cloudtrail/Interface/GenerateQueryCommandOutput/)

</details>
<details>
<summary>
Expand Down
17 changes: 17 additions & 0 deletions clients/client-cloudtrail/src/CloudTrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ import {
EnableFederationCommandInput,
EnableFederationCommandOutput,
} from "./commands/EnableFederationCommand";
import {
GenerateQueryCommand,
GenerateQueryCommandInput,
GenerateQueryCommandOutput,
} from "./commands/GenerateQueryCommand";
import { GetChannelCommand, GetChannelCommandInput, GetChannelCommandOutput } from "./commands/GetChannelCommand";
import {
GetEventDataStoreCommand,
Expand Down Expand Up @@ -196,6 +201,7 @@ const commands = {
DescribeTrailsCommand,
DisableFederationCommand,
EnableFederationCommand,
GenerateQueryCommand,
GetChannelCommand,
GetEventDataStoreCommand,
GetEventSelectorsCommand,
Expand Down Expand Up @@ -429,6 +435,17 @@ export interface CloudTrail {
cb: (err: any, data?: EnableFederationCommandOutput) => void
): void;

/**
* @see {@link GenerateQueryCommand}
*/
generateQuery(args: GenerateQueryCommandInput, options?: __HttpHandlerOptions): Promise<GenerateQueryCommandOutput>;
generateQuery(args: GenerateQueryCommandInput, cb: (err: any, data?: GenerateQueryCommandOutput) => void): void;
generateQuery(
args: GenerateQueryCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GenerateQueryCommandOutput) => void
): void;

/**
* @see {@link GetChannelCommand}
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-cloudtrail/src/CloudTrailClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { DescribeQueryCommandInput, DescribeQueryCommandOutput } from "./command
import { DescribeTrailsCommandInput, DescribeTrailsCommandOutput } from "./commands/DescribeTrailsCommand";
import { DisableFederationCommandInput, DisableFederationCommandOutput } from "./commands/DisableFederationCommand";
import { EnableFederationCommandInput, EnableFederationCommandOutput } from "./commands/EnableFederationCommand";
import { GenerateQueryCommandInput, GenerateQueryCommandOutput } from "./commands/GenerateQueryCommand";
import { GetChannelCommandInput, GetChannelCommandOutput } from "./commands/GetChannelCommand";
import { GetEventDataStoreCommandInput, GetEventDataStoreCommandOutput } from "./commands/GetEventDataStoreCommand";
import { GetEventSelectorsCommandInput, GetEventSelectorsCommandOutput } from "./commands/GetEventSelectorsCommand";
Expand Down Expand Up @@ -170,6 +171,7 @@ export type ServiceInputTypes =
| DescribeTrailsCommandInput
| DisableFederationCommandInput
| EnableFederationCommandInput
| GenerateQueryCommandInput
| GetChannelCommandInput
| GetEventDataStoreCommandInput
| GetEventSelectorsCommandInput
Expand Down Expand Up @@ -224,6 +226,7 @@ export type ServiceOutputTypes =
| DescribeTrailsCommandOutput
| DisableFederationCommandOutput
| EnableFederationCommandOutput
| GenerateQueryCommandOutput
| GetChannelCommandOutput
| GetEventDataStoreCommandOutput
| GetEventSelectorsCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface DescribeQueryCommandOutput extends DescribeQueryResponse, __Met
* // ErrorMessage: "STRING_VALUE",
* // DeliveryS3Uri: "STRING_VALUE",
* // DeliveryStatus: "SUCCESS" || "FAILED" || "FAILED_SIGNING_FILE" || "PENDING" || "RESOURCE_NOT_FOUND" || "ACCESS_DENIED" || "ACCESS_DENIED_SIGNING_FILE" || "CANCELLED" || "UNKNOWN",
* // Prompt: "STRING_VALUE",
* // };
*
* ```
Expand Down
139 changes: 139 additions & 0 deletions clients/client-cloudtrail/src/commands/GenerateQueryCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { CloudTrailClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudTrailClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { GenerateQueryRequest, GenerateQueryResponse } from "../models/models_0";
import { de_GenerateQueryCommand, se_GenerateQueryCommand } from "../protocols/Aws_json1_1";

/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link GenerateQueryCommand}.
*/
export interface GenerateQueryCommandInput extends GenerateQueryRequest {}
/**
* @public
*
* The output of {@link GenerateQueryCommand}.
*/
export interface GenerateQueryCommandOutput extends GenerateQueryResponse, __MetadataBearer {}

/**
* <p>
* Generates a query from a natural language prompt. This operation uses generative artificial intelligence
* (generative AI) to produce a ready-to-use SQL query from the prompt.
* </p>
* <p>The prompt can be a question or a statement about the event data
* in your event data store. For example, you can enter prompts like "What are my
* top errors in the past month?" and “Give me a list of users that used SNS.”</p>
* <p>The prompt must be in English. For information about limitations, permissions, and supported Regions, see
* <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html">Create CloudTrail Lake queries from natural language prompts</a>
* in the <i>CloudTrail </i> user guide.</p>
* <note>
* <p>Do not include any personally identifying, confidential, or sensitive information
* in your prompts.</p>
* <p>This feature uses generative AI large language models (LLMs); we recommend double-checking the
* LLM response.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CloudTrailClient, GenerateQueryCommand } from "@aws-sdk/client-cloudtrail"; // ES Modules import
* // const { CloudTrailClient, GenerateQueryCommand } = require("@aws-sdk/client-cloudtrail"); // CommonJS import
* const client = new CloudTrailClient(config);
* const input = { // GenerateQueryRequest
* EventDataStores: [ // EventDataStoreList // required
* "STRING_VALUE",
* ],
* Prompt: "STRING_VALUE", // required
* };
* const command = new GenerateQueryCommand(input);
* const response = await client.send(command);
* // { // GenerateQueryResponse
* // QueryStatement: "STRING_VALUE",
* // QueryAlias: "STRING_VALUE",
* // };
*
* ```
*
* @param GenerateQueryCommandInput - {@link GenerateQueryCommandInput}
* @returns {@link GenerateQueryCommandOutput}
* @see {@link GenerateQueryCommandInput} for command's `input` shape.
* @see {@link GenerateQueryCommandOutput} for command's `response` shape.
* @see {@link CloudTrailClientResolvedConfig | config} for CloudTrailClient's `config` shape.
*
* @throws {@link EventDataStoreARNInvalidException} (client fault)
* <p>The specified event data store ARN is not valid or does not map to an event data store
* in your account.</p>
*
* @throws {@link EventDataStoreNotFoundException} (client fault)
* <p>The specified event data store was not found.</p>
*
* @throws {@link GenerateResponseException} (client fault)
* <p>
* This exception is thrown when a valid query could not be generated for the provided prompt.
* </p>
*
* @throws {@link InactiveEventDataStoreException} (client fault)
* <p>The event data store is inactive.</p>
*
* @throws {@link InvalidParameterException} (client fault)
* <p>The request includes a parameter that is not valid.</p>
*
* @throws {@link NoManagementAccountSLRExistsException} (client fault)
* <p> This exception is thrown when the management account does not have a service-linked
* role. </p>
*
* @throws {@link OperationNotPermittedException} (client fault)
* <p>This exception is thrown when the requested operation is not permitted.</p>
*
* @throws {@link UnsupportedOperationException} (client fault)
* <p>This exception is thrown when the requested operation is not supported.</p>
*
* @throws {@link CloudTrailServiceException}
* <p>Base exception class for all service exceptions from CloudTrail service.</p>
*
* @public
*/
export class GenerateQueryCommand extends $Command
.classBuilder<
GenerateQueryCommandInput,
GenerateQueryCommandOutput,
CloudTrailClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: CloudTrailClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("CloudTrail_20131101", "GenerateQuery", {})
.n("CloudTrailClient", "GenerateQueryCommand")
.f(void 0, void 0)
.ser(se_GenerateQueryCommand)
.de(de_GenerateQueryCommand)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: GenerateQueryRequest;
output: GenerateQueryResponse;
};
sdk: {
input: GenerateQueryCommandInput;
output: GenerateQueryCommandOutput;
};
};
}
6 changes: 6 additions & 0 deletions clients/client-cloudtrail/src/commands/RemoveTagsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export interface RemoveTagsCommandOutput extends RemoveTagsResponse, __MetadataB
* <code>arn:aws:cloudtrail:us-east-2:123456789012:channel/01234567890</code>
* </p>
*
* @throws {@link ConflictException} (client fault)
* <p>This exception is thrown when the specified resource is not ready for an operation. This
* can occur when you try to run an operation on a resource before CloudTrail has time
* to fully load the resource, or because another operation is modifying the resource. If this exception occurs, wait a few minutes, and then try the
* operation again.</p>
*
* @throws {@link EventDataStoreARNInvalidException} (client fault)
* <p>The specified event data store ARN is not valid or does not map to an event data store
* in your account.</p>
Expand Down
1 change: 1 addition & 0 deletions clients/client-cloudtrail/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from "./DescribeQueryCommand";
export * from "./DescribeTrailsCommand";
export * from "./DisableFederationCommand";
export * from "./EnableFederationCommand";
export * from "./GenerateQueryCommand";
export * from "./GetChannelCommand";
export * from "./GetEventDataStoreCommand";
export * from "./GetEventSelectorsCommand";
Expand Down
Loading

0 comments on commit 93b16b2

Please sign in to comment.