Skip to content

Commit 93b16b2

Browse files
author
awstools
committed
feat(client-cloudtrail): This release adds a new API GenerateQuery that 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.
1 parent 8ee2e53 commit 93b16b2

File tree

10 files changed

+554
-389
lines changed

10 files changed

+554
-389
lines changed

clients/client-cloudtrail/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ EnableFederation
330330

331331
[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/)
332332

333+
</details>
334+
<details>
335+
<summary>
336+
GenerateQuery
337+
</summary>
338+
339+
[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/)
340+
333341
</details>
334342
<details>
335343
<summary>

clients/client-cloudtrail/src/CloudTrail.ts

+17
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ import {
5757
EnableFederationCommandInput,
5858
EnableFederationCommandOutput,
5959
} from "./commands/EnableFederationCommand";
60+
import {
61+
GenerateQueryCommand,
62+
GenerateQueryCommandInput,
63+
GenerateQueryCommandOutput,
64+
} from "./commands/GenerateQueryCommand";
6065
import { GetChannelCommand, GetChannelCommandInput, GetChannelCommandOutput } from "./commands/GetChannelCommand";
6166
import {
6267
GetEventDataStoreCommand,
@@ -196,6 +201,7 @@ const commands = {
196201
DescribeTrailsCommand,
197202
DisableFederationCommand,
198203
EnableFederationCommand,
204+
GenerateQueryCommand,
199205
GetChannelCommand,
200206
GetEventDataStoreCommand,
201207
GetEventSelectorsCommand,
@@ -429,6 +435,17 @@ export interface CloudTrail {
429435
cb: (err: any, data?: EnableFederationCommandOutput) => void
430436
): void;
431437

438+
/**
439+
* @see {@link GenerateQueryCommand}
440+
*/
441+
generateQuery(args: GenerateQueryCommandInput, options?: __HttpHandlerOptions): Promise<GenerateQueryCommandOutput>;
442+
generateQuery(args: GenerateQueryCommandInput, cb: (err: any, data?: GenerateQueryCommandOutput) => void): void;
443+
generateQuery(
444+
args: GenerateQueryCommandInput,
445+
options: __HttpHandlerOptions,
446+
cb: (err: any, data?: GenerateQueryCommandOutput) => void
447+
): void;
448+
432449
/**
433450
* @see {@link GetChannelCommand}
434451
*/

clients/client-cloudtrail/src/CloudTrailClient.ts

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import { DescribeQueryCommandInput, DescribeQueryCommandOutput } from "./command
7979
import { DescribeTrailsCommandInput, DescribeTrailsCommandOutput } from "./commands/DescribeTrailsCommand";
8080
import { DisableFederationCommandInput, DisableFederationCommandOutput } from "./commands/DisableFederationCommand";
8181
import { EnableFederationCommandInput, EnableFederationCommandOutput } from "./commands/EnableFederationCommand";
82+
import { GenerateQueryCommandInput, GenerateQueryCommandOutput } from "./commands/GenerateQueryCommand";
8283
import { GetChannelCommandInput, GetChannelCommandOutput } from "./commands/GetChannelCommand";
8384
import { GetEventDataStoreCommandInput, GetEventDataStoreCommandOutput } from "./commands/GetEventDataStoreCommand";
8485
import { GetEventSelectorsCommandInput, GetEventSelectorsCommandOutput } from "./commands/GetEventSelectorsCommand";
@@ -170,6 +171,7 @@ export type ServiceInputTypes =
170171
| DescribeTrailsCommandInput
171172
| DisableFederationCommandInput
172173
| EnableFederationCommandInput
174+
| GenerateQueryCommandInput
173175
| GetChannelCommandInput
174176
| GetEventDataStoreCommandInput
175177
| GetEventSelectorsCommandInput
@@ -224,6 +226,7 @@ export type ServiceOutputTypes =
224226
| DescribeTrailsCommandOutput
225227
| DisableFederationCommandOutput
226228
| EnableFederationCommandOutput
229+
| GenerateQueryCommandOutput
227230
| GetChannelCommandOutput
228231
| GetEventDataStoreCommandOutput
229232
| GetEventSelectorsCommandOutput

clients/client-cloudtrail/src/commands/DescribeQueryCommand.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface DescribeQueryCommandOutput extends DescribeQueryResponse, __Met
6161
* // ErrorMessage: "STRING_VALUE",
6262
* // DeliveryS3Uri: "STRING_VALUE",
6363
* // DeliveryStatus: "SUCCESS" || "FAILED" || "FAILED_SIGNING_FILE" || "PENDING" || "RESOURCE_NOT_FOUND" || "ACCESS_DENIED" || "ACCESS_DENIED_SIGNING_FILE" || "CANCELLED" || "UNKNOWN",
64+
* // Prompt: "STRING_VALUE",
6465
* // };
6566
*
6667
* ```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { CloudTrailClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudTrailClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { GenerateQueryRequest, GenerateQueryResponse } from "../models/models_0";
10+
import { de_GenerateQueryCommand, se_GenerateQueryCommand } from "../protocols/Aws_json1_1";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link GenerateQueryCommand}.
21+
*/
22+
export interface GenerateQueryCommandInput extends GenerateQueryRequest {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link GenerateQueryCommand}.
27+
*/
28+
export interface GenerateQueryCommandOutput extends GenerateQueryResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>
32+
* Generates a query from a natural language prompt. This operation uses generative artificial intelligence
33+
* (generative AI) to produce a ready-to-use SQL query from the prompt.
34+
* </p>
35+
* <p>The prompt can be a question or a statement about the event data
36+
* in your event data store. For example, you can enter prompts like "What are my
37+
* top errors in the past month?" and “Give me a list of users that used SNS.”</p>
38+
* <p>The prompt must be in English. For information about limitations, permissions, and supported Regions, see
39+
* <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html">Create CloudTrail Lake queries from natural language prompts</a>
40+
* in the <i>CloudTrail </i> user guide.</p>
41+
* <note>
42+
* <p>Do not include any personally identifying, confidential, or sensitive information
43+
* in your prompts.</p>
44+
* <p>This feature uses generative AI large language models (LLMs); we recommend double-checking the
45+
* LLM response.</p>
46+
* </note>
47+
* @example
48+
* Use a bare-bones client and the command you need to make an API call.
49+
* ```javascript
50+
* import { CloudTrailClient, GenerateQueryCommand } from "@aws-sdk/client-cloudtrail"; // ES Modules import
51+
* // const { CloudTrailClient, GenerateQueryCommand } = require("@aws-sdk/client-cloudtrail"); // CommonJS import
52+
* const client = new CloudTrailClient(config);
53+
* const input = { // GenerateQueryRequest
54+
* EventDataStores: [ // EventDataStoreList // required
55+
* "STRING_VALUE",
56+
* ],
57+
* Prompt: "STRING_VALUE", // required
58+
* };
59+
* const command = new GenerateQueryCommand(input);
60+
* const response = await client.send(command);
61+
* // { // GenerateQueryResponse
62+
* // QueryStatement: "STRING_VALUE",
63+
* // QueryAlias: "STRING_VALUE",
64+
* // };
65+
*
66+
* ```
67+
*
68+
* @param GenerateQueryCommandInput - {@link GenerateQueryCommandInput}
69+
* @returns {@link GenerateQueryCommandOutput}
70+
* @see {@link GenerateQueryCommandInput} for command's `input` shape.
71+
* @see {@link GenerateQueryCommandOutput} for command's `response` shape.
72+
* @see {@link CloudTrailClientResolvedConfig | config} for CloudTrailClient's `config` shape.
73+
*
74+
* @throws {@link EventDataStoreARNInvalidException} (client fault)
75+
* <p>The specified event data store ARN is not valid or does not map to an event data store
76+
* in your account.</p>
77+
*
78+
* @throws {@link EventDataStoreNotFoundException} (client fault)
79+
* <p>The specified event data store was not found.</p>
80+
*
81+
* @throws {@link GenerateResponseException} (client fault)
82+
* <p>
83+
* This exception is thrown when a valid query could not be generated for the provided prompt.
84+
* </p>
85+
*
86+
* @throws {@link InactiveEventDataStoreException} (client fault)
87+
* <p>The event data store is inactive.</p>
88+
*
89+
* @throws {@link InvalidParameterException} (client fault)
90+
* <p>The request includes a parameter that is not valid.</p>
91+
*
92+
* @throws {@link NoManagementAccountSLRExistsException} (client fault)
93+
* <p> This exception is thrown when the management account does not have a service-linked
94+
* role. </p>
95+
*
96+
* @throws {@link OperationNotPermittedException} (client fault)
97+
* <p>This exception is thrown when the requested operation is not permitted.</p>
98+
*
99+
* @throws {@link UnsupportedOperationException} (client fault)
100+
* <p>This exception is thrown when the requested operation is not supported.</p>
101+
*
102+
* @throws {@link CloudTrailServiceException}
103+
* <p>Base exception class for all service exceptions from CloudTrail service.</p>
104+
*
105+
* @public
106+
*/
107+
export class GenerateQueryCommand extends $Command
108+
.classBuilder<
109+
GenerateQueryCommandInput,
110+
GenerateQueryCommandOutput,
111+
CloudTrailClientResolvedConfig,
112+
ServiceInputTypes,
113+
ServiceOutputTypes
114+
>()
115+
.ep(commonParams)
116+
.m(function (this: any, Command: any, cs: any, config: CloudTrailClientResolvedConfig, o: any) {
117+
return [
118+
getSerdePlugin(config, this.serialize, this.deserialize),
119+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
120+
];
121+
})
122+
.s("CloudTrail_20131101", "GenerateQuery", {})
123+
.n("CloudTrailClient", "GenerateQueryCommand")
124+
.f(void 0, void 0)
125+
.ser(se_GenerateQueryCommand)
126+
.de(de_GenerateQueryCommand)
127+
.build() {
128+
/** @internal type navigation helper, not in runtime. */
129+
protected declare static __types: {
130+
api: {
131+
input: GenerateQueryRequest;
132+
output: GenerateQueryResponse;
133+
};
134+
sdk: {
135+
input: GenerateQueryCommandInput;
136+
output: GenerateQueryCommandOutput;
137+
};
138+
};
139+
}

clients/client-cloudtrail/src/commands/RemoveTagsCommand.ts

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export interface RemoveTagsCommandOutput extends RemoveTagsResponse, __MetadataB
7474
* <code>arn:aws:cloudtrail:us-east-2:123456789012:channel/01234567890</code>
7575
* </p>
7676
*
77+
* @throws {@link ConflictException} (client fault)
78+
* <p>This exception is thrown when the specified resource is not ready for an operation. This
79+
* can occur when you try to run an operation on a resource before CloudTrail has time
80+
* 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
81+
* operation again.</p>
82+
*
7783
* @throws {@link EventDataStoreARNInvalidException} (client fault)
7884
* <p>The specified event data store ARN is not valid or does not map to an event data store
7985
* in your account.</p>

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

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from "./DescribeQueryCommand";
1313
export * from "./DescribeTrailsCommand";
1414
export * from "./DisableFederationCommand";
1515
export * from "./EnableFederationCommand";
16+
export * from "./GenerateQueryCommand";
1617
export * from "./GetChannelCommand";
1718
export * from "./GetEventDataStoreCommand";
1819
export * from "./GetEventSelectorsCommand";

0 commit comments

Comments
 (0)