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 AddPermissionRequest extends Omit<
7 sns.AddPermissionInput,
8 "TopicArn"
9> {}
10
11/**
12 * Runtime binding for `sns:AddPermission`.
13 *
14 * Bind this operation to a {@link Topic} inside a function runtime to grant
15 * other AWS accounts access to topic actions by adding a labeled statement
16 * to the topic's access policy. The binding grants the host function
17 * `sns:AddPermission` on the topic. Provide the `AddPermissionHttp` layer on
18 * the Function to implement the binding.
19 * ### Managing Topic Permissions
20 * **Example:** Allow Another Account to Publish
21 * ```typescript
22 * // init (provide SNS.AddPermissionHttp on the Function)
23 * const addPermission = yield* SNS.AddPermission(topic);
24 *
25 * // runtime
26 * yield* addPermission({
27 * Label: "PartnerPublish",
28 * AWSAccountId: ["123456789012"],
29 * ActionName: ["Publish"],
30 * });
31 * ```
32 *
33 * @binding
34 */
35export interface AddPermission extends Binding.Service<
36 AddPermission,
37 "AWS.SNS.AddPermission",
38 (
39 topic: Topic,
40 ) => Effect.Effect<
41 (
42 request: AddPermissionRequest,
43 ) => Effect.Effect<sns.AddPermissionResponse, sns.AddPermissionError>
44 >
45> {}
46
47export const AddPermission = Binding.Service<AddPermission>(
48 "AWS.SNS.AddPermission",
49);