| 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 `CreateWorkspaceServiceAccount` operation (IAM |
| 8 | * action `grafana:CreateWorkspaceServiceAccount`), scoped to one |
| 9 | * {@link Workspace}. |
| 10 | * |
| 11 | * Creates a Grafana service account in the workspace — a non-user identity |
| 12 | * for machine access to the Grafana HTTP API (dashboards, alerts, data |
| 13 | * sources). Mint API tokens for it with |
| 14 | * `CreateWorkspaceServiceAccountToken`. Requires Grafana 9 or newer. |
| 15 | * Provide the implementation with |
| 16 | * `Effect.provide(AWS.Grafana.CreateWorkspaceServiceAccountHttp)`. |
| 17 | * ### Managing Service Accounts |
| 18 | * **Example:** Create an Automation Service Account |
| 19 | * ```typescript |
| 20 | * const createServiceAccount = |
| 21 | * yield* Grafana.CreateWorkspaceServiceAccount(workspace); |
| 22 | * |
| 23 | * const account = yield* createServiceAccount({ |
| 24 | * name: "dashboard-automation", |
| 25 | * grafanaRole: "EDITOR", |
| 26 | * }); |
| 27 | * // account.id → the service account id used for token operations |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface CreateWorkspaceServiceAccount extends Binding.Service< |
| 33 | CreateWorkspaceServiceAccount, |
| 34 | "AWS.Grafana.CreateWorkspaceServiceAccount", |
| 35 | ( |
| 36 | workspace: Workspace, |
| 37 | ) => Effect.Effect< |
| 38 | ( |
| 39 | request: Omit< |
| 40 | grafana.CreateWorkspaceServiceAccountRequest, |
| 41 | "workspaceId" |
| 42 | >, |
| 43 | ) => Effect.Effect< |
| 44 | grafana.CreateWorkspaceServiceAccountResponse, |
| 45 | grafana.CreateWorkspaceServiceAccountError |
| 46 | > |
| 47 | > |
| 48 | > {} |
| 49 | export const CreateWorkspaceServiceAccount = |
| 50 | Binding.Service<CreateWorkspaceServiceAccount>( |
| 51 | "AWS.Grafana.CreateWorkspaceServiceAccount", |
| 52 | ); |