| 1 | import type * as kafka from "@distilled.cloud/aws/kafka"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { ServerlessCluster } from "./ServerlessCluster.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for the `CreateTopic` operation (IAM action |
| 8 | * `kafka:CreateTopic`), scoped to one {@link ServerlessCluster}. |
| 9 | * |
| 10 | * Creates a Kafka topic on the bound cluster through the MSK control plane — |
| 11 | * no Kafka admin client or VPC connectivity required. Provide the |
| 12 | * implementation with `Effect.provide(AWS.Kafka.CreateTopicHttp)`. |
| 13 | * ### Managing Topics |
| 14 | * **Example:** Create a Topic |
| 15 | * ```typescript |
| 16 | * const createTopic = yield* Kafka.CreateTopic(cluster); |
| 17 | * |
| 18 | * const topic = yield* createTopic({ |
| 19 | * TopicName: "orders", |
| 20 | * PartitionCount: 3, |
| 21 | * }); |
| 22 | * // topic.TopicArn, topic.Status → "CREATING" | "ACTIVE" |
| 23 | * ``` |
| 24 | * |
| 25 | * @binding |
| 26 | */ |
| 27 | export interface CreateTopic extends Binding.Service< |
| 28 | CreateTopic, |
| 29 | "AWS.Kafka.CreateTopic", |
| 30 | ( |
| 31 | cluster: ServerlessCluster, |
| 32 | ) => Effect.Effect< |
| 33 | ( |
| 34 | request: Omit<kafka.CreateTopicRequest, "ClusterArn">, |
| 35 | ) => Effect.Effect<kafka.CreateTopicResponse, kafka.CreateTopicError> |
| 36 | > |
| 37 | > {} |
| 38 | export const CreateTopic = Binding.Service<CreateTopic>( |
| 39 | "AWS.Kafka.CreateTopic", |
| 40 | ); |