| 1 | import type * as mediapackagev2 from "@distilled.cloud/aws/mediapackagev2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { OriginEndpoint } from "./OriginEndpoint.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `mediapackagev2:CreateHarvestJob`. |
| 8 | * |
| 9 | * Exports a clip of previously streamed content from the bound |
| 10 | * {@link OriginEndpoint} to an S3 bucket as a live-to-VOD asset — e.g. a |
| 11 | * Lambda that clips a highlight when an operator flags a moment. The |
| 12 | * endpoint must have a startover window covering the requested schedule, |
| 13 | * and the destination bucket needs a policy granting the |
| 14 | * `mediapackagev2.amazonaws.com` service principal write access. The |
| 15 | * endpoint's group, channel, and name are injected from the binding. |
| 16 | * Provide the implementation with |
| 17 | * `Effect.provide(AWS.MediaPackageV2.CreateHarvestJobHttp)`. |
| 18 | * ### Harvesting Live-to-VOD Clips |
| 19 | * **Example:** Harvest the Last Five Minutes to S3 |
| 20 | * ```typescript |
| 21 | * // init — bind the operation to the endpoint |
| 22 | * const createHarvestJob = yield* AWS.MediaPackageV2.CreateHarvestJob(endpoint); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const job = yield* createHarvestJob({ |
| 26 | * HarvestedManifests: { HlsManifests: [{ ManifestName: "index" }] }, |
| 27 | * ScheduleConfiguration: { |
| 28 | * StartTime: new Date(Date.now() - 5 * 60_000), |
| 29 | * EndTime: new Date(), |
| 30 | * }, |
| 31 | * Destination: { |
| 32 | * S3Destination: { BucketName: "my-clips", DestinationPath: "highlights/" }, |
| 33 | * }, |
| 34 | * }); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface CreateHarvestJob extends Binding.Service< |
| 40 | CreateHarvestJob, |
| 41 | "AWS.MediaPackageV2.CreateHarvestJob", |
| 42 | ( |
| 43 | endpoint: OriginEndpoint, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request: Omit< |
| 47 | mediapackagev2.CreateHarvestJobRequest, |
| 48 | "ChannelGroupName" | "ChannelName" | "OriginEndpointName" |
| 49 | >, |
| 50 | ) => Effect.Effect< |
| 51 | mediapackagev2.CreateHarvestJobResponse, |
| 52 | mediapackagev2.CreateHarvestJobError |
| 53 | > |
| 54 | > |
| 55 | > {} |
| 56 | export const CreateHarvestJob = Binding.Service<CreateHarvestJob>( |
| 57 | "AWS.MediaPackageV2.CreateHarvestJob", |
| 58 | ); |