1import * as sns from "@distilled.cloud/aws/sns";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Topic } from "./Topic.ts";
5
6export interface SubscribeRequest extends Omit<
7 sns.SubscribeInput,
8 "TopicArn"
9> {}
10
11/**
12 * Runtime binding for `sns:Subscribe`.
13 *
14 * Bind this operation to a {@link Topic} to subscribe endpoints (email,
15 * sms, https, sqs, ...) to the topic at runtime — for example subscribing a
16 * user's email address from an API handler. The `TopicArn` is injected
17 * automatically.
18 * Provide the `SubscribeHttp` layer on the Function to implement the binding.
19 * ### Subscribing Endpoints
20 * **Example:** Subscribe an Email Address
21 * ```typescript
22 * const subscribe = yield* SNS.Subscribe(topic);
23 * const response = yield* subscribe({
24 * Protocol: "email",
25 * Endpoint: "user@example.com",
26 * });
27 * ```
28 *
29 * @binding
30 */
31export interface Subscribe extends Binding.Service<
32 Subscribe,
33 "AWS.SNS.Subscribe",
34 (
35 topic: Topic,
36 ) => Effect.Effect<
37 (
38 request: SubscribeRequest,
39 ) => Effect.Effect<sns.SubscribeResponse, sns.SubscribeError>
40 >
41> {}
42
43export const Subscribe = Binding.Service<Subscribe>("AWS.SNS.Subscribe");