| 1 | import type * as cloudtrail from "@distilled.cloud/aws/cloudtrail"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { EventDataStore } from "./EventDataStore.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `cloudtrail:GenerateQuery`. |
| 8 | * |
| 9 | * Generates a CloudTrail Lake SQL statement from a natural-language prompt |
| 10 | * against the bound {@link EventDataStore} (the store list is injected from |
| 11 | * the binding). Provide the implementation with |
| 12 | * `Effect.provide(AWS.CloudTrail.GenerateQueryHttp)`. |
| 13 | * ### Querying CloudTrail Lake |
| 14 | * **Example:** Generate SQL from a Prompt |
| 15 | * ```typescript |
| 16 | * // init — bind the operation to the event data store |
| 17 | * const generateQuery = yield* AWS.CloudTrail.GenerateQuery(store); |
| 18 | * |
| 19 | * // runtime |
| 20 | * const result = yield* generateQuery({ |
| 21 | * Prompt: "What are my top errors in the past month?", |
| 22 | * }); |
| 23 | * console.log(result.QueryStatement); |
| 24 | * ``` |
| 25 | * |
| 26 | * @binding |
| 27 | */ |
| 28 | export interface GenerateQuery extends Binding.Service< |
| 29 | GenerateQuery, |
| 30 | "AWS.CloudTrail.GenerateQuery", |
| 31 | ( |
| 32 | store: EventDataStore, |
| 33 | ) => Effect.Effect< |
| 34 | ( |
| 35 | request: Omit<cloudtrail.GenerateQueryRequest, "EventDataStores">, |
| 36 | ) => Effect.Effect< |
| 37 | cloudtrail.GenerateQueryResponse, |
| 38 | cloudtrail.GenerateQueryError |
| 39 | > |
| 40 | > |
| 41 | > {} |
| 42 | export const GenerateQuery = Binding.Service<GenerateQuery>( |
| 43 | "AWS.CloudTrail.GenerateQuery", |
| 44 | ); |