| 1 | import type * as grafana from "@distilled.cloud/aws/grafana"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Workspace } from "./Workspace.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for the `UpdatePermissions` operation (IAM action |
| 8 | * `grafana:UpdatePermissions`), scoped to one {@link Workspace}. |
| 9 | * |
| 10 | * Grants or revokes the `ADMIN`, `EDITOR`, or `VIEWER` role for IAM Identity |
| 11 | * Center users and groups in the workspace. Rejected instructions come back |
| 12 | * in the response's `errors` list rather than failing the call. Provide the |
| 13 | * implementation with `Effect.provide(AWS.Grafana.UpdatePermissionsHttp)`. |
| 14 | * ### Managing Permissions |
| 15 | * **Example:** Grant a User the Editor Role |
| 16 | * ```typescript |
| 17 | * const updatePermissions = yield* Grafana.UpdatePermissions(workspace); |
| 18 | * |
| 19 | * const { errors } = yield* updatePermissions({ |
| 20 | * updateInstructionBatch: [ |
| 21 | * { |
| 22 | * action: "ADD", |
| 23 | * role: "EDITOR", |
| 24 | * users: [{ id: userId, type: "SSO_USER" }], |
| 25 | * }, |
| 26 | * ], |
| 27 | * }); |
| 28 | * // errors → [] when every instruction applied |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface UpdatePermissions extends Binding.Service< |
| 34 | UpdatePermissions, |
| 35 | "AWS.Grafana.UpdatePermissions", |
| 36 | ( |
| 37 | workspace: Workspace, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: Omit<grafana.UpdatePermissionsRequest, "workspaceId">, |
| 41 | ) => Effect.Effect< |
| 42 | grafana.UpdatePermissionsResponse, |
| 43 | grafana.UpdatePermissionsError |
| 44 | > |
| 45 | > |
| 46 | > {} |
| 47 | export const UpdatePermissions = Binding.Service<UpdatePermissions>( |
| 48 | "AWS.Grafana.UpdatePermissions", |
| 49 | ); |