| 1 | import type * as Effect from "effect/Effect"; |
| 2 | import * as Binding from "../../Binding.ts"; |
| 3 | import type { SecretBindingTarget } from "./BindingHttp.ts"; |
| 4 | import type { ReadSecretClient } from "./ReadSecret.ts"; |
| 5 | import type { WriteSecretClient } from "./WriteSecret.ts"; |
| 6 | |
| 7 | export interface ReadWriteSecretClient |
| 8 | extends ReadSecretClient, WriteSecretClient {} |
| 9 | |
| 10 | /** |
| 11 | * Read and version-management access to a Secret Manager {@link Secret}. |
| 12 | * No predefined role covers both, so this grants |
| 13 | * `roles/secretmanager.secretAccessor` and |
| 14 | * `roles/secretmanager.secretVersionManager` on the secret only. |
| 15 | * |
| 16 | * ### Reading and rotating |
| 17 | * **Example:** Rotate and read back |
| 18 | * ```typescript |
| 19 | * const apiKey = yield* GCP.SecretManager.ReadWriteSecret(secret); |
| 20 | * const current = yield* apiKey.access(); |
| 21 | * yield* apiKey.addVersion(rotate(current)); |
| 22 | * // …provided with Effect.provide(GCP.SecretManager.ReadWriteSecretHttp) |
| 23 | * ``` |
| 24 | * |
| 25 | * @binding |
| 26 | * @category SecretManager |
| 27 | */ |
| 28 | export interface ReadWriteSecret extends Binding.Service< |
| 29 | ReadWriteSecret, |
| 30 | "GCP.SecretManager.ReadWriteSecret", |
| 31 | (secret: SecretBindingTarget) => Effect.Effect<ReadWriteSecretClient> |
| 32 | > {} |
| 33 | |
| 34 | export const ReadWriteSecret = Binding.Service<ReadWriteSecret>( |
| 35 | "GCP.SecretManager.ReadWriteSecret", |
| 36 | ); |