| 1 | import type * as backup from "@distilled.cloud/aws/backup"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Role } from "../IAM/Role.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `StartRestoreJob` request with `IamRoleArn` defaulting to the bound |
| 8 | * restore role. |
| 9 | */ |
| 10 | export interface StartRestoreJobRequest extends Omit< |
| 11 | backup.StartRestoreJobInput, |
| 12 | "IamRoleArn" |
| 13 | > { |
| 14 | /** |
| 15 | * IAM role AWS Backup assumes to create the restored resource. |
| 16 | * @default the restore role bound via `StartRestoreJob(role)` |
| 17 | */ |
| 18 | IamRoleArn?: string; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Runtime binding for the `StartRestoreJob` operation (IAM actions |
| 23 | * `backup:StartRestoreJob` + `iam:PassRole` on the restore role) — restore a |
| 24 | * recovery point from a deployed Function. |
| 25 | * |
| 26 | * The binding is constructed with the **restore role** (the IAM role AWS |
| 27 | * Backup assumes to recreate the resource; its trust policy must allow |
| 28 | * `backup.amazonaws.com`), injected as `IamRoleArn` unless the request |
| 29 | * overrides it. `backup:StartRestoreJob` authorizes on the recovery point's |
| 30 | * underlying resource ARN, so the grant is on `*`. Provide the |
| 31 | * implementation with `Effect.provide(AWS.Backup.StartRestoreJobHttp)`. |
| 32 | * ### Restoring Recovery Points |
| 33 | * **Example:** Restore The Latest Recovery Point |
| 34 | * ```typescript |
| 35 | * const startRestoreJob = yield* AWS.Backup.StartRestoreJob(restoreRole); |
| 36 | * |
| 37 | * const job = yield* startRestoreJob({ |
| 38 | * RecoveryPointArn: recoveryPointArn, |
| 39 | * Metadata: restoreMetadata, |
| 40 | * }); |
| 41 | * yield* Effect.log(`restore job ${job.RestoreJobId} started`); |
| 42 | * ``` |
| 43 | * |
| 44 | * @binding |
| 45 | */ |
| 46 | export interface StartRestoreJob extends Binding.Service< |
| 47 | StartRestoreJob, |
| 48 | "AWS.Backup.StartRestoreJob", |
| 49 | <R extends Role>( |
| 50 | restoreRole: R, |
| 51 | ) => Effect.Effect< |
| 52 | ( |
| 53 | request: StartRestoreJobRequest, |
| 54 | ) => Effect.Effect< |
| 55 | backup.StartRestoreJobOutput, |
| 56 | backup.StartRestoreJobError |
| 57 | > |
| 58 | > |
| 59 | > {} |
| 60 | export const StartRestoreJob = Binding.Service<StartRestoreJob>( |
| 61 | "AWS.Backup.StartRestoreJob", |
| 62 | ); |