1import type * as backupsearch from "@distilled.cloud/aws/backupsearch";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { SearchJob } from "./SearchJob.ts";
5
6/**
7 * Runtime binding for `backup-search:GetSearchJob`.
8 *
9 * Retrieves the bound search job's metadata and progress — its `Status`
10 * (`RUNNING`, `COMPLETED`, `STOPPED`, `FAILED`), item/backup counts, and
11 * completion time. BackupSearch emits no EventBridge events, so polling this
12 * operation until `Status` is terminal is how a consumer knows the results
13 * returned by `ListSearchJobResults` are final. Provide the implementation
14 * with `Effect.provide(AWS.BackupSearch.GetSearchJobHttp)`.
15 * ### Polling Search Progress
16 * **Example:** Wait for the Search Job to Complete
17 * ```typescript
18 * // init — bind the operation to the search job
19 * const getSearchJob = yield* AWS.BackupSearch.GetSearchJob(search);
20 *
21 * // runtime — poll until the job reaches a terminal status
22 * const job = yield* getSearchJob().pipe(
23 * Effect.repeat({
24 * schedule: Schedule.spaced("5 seconds"),
25 * until: (j) => j.Status !== "RUNNING",
26 * times: 24,
27 * }),
28 * );
29 * console.log(job.Status, job.SearchProgress?.ItemsMatchedCount);
30 * ```
31 *
32 * @binding
33 */
34export interface GetSearchJob extends Binding.Service<
35 GetSearchJob,
36 "AWS.BackupSearch.GetSearchJob",
37 (
38 searchJob: SearchJob,
39 ) => Effect.Effect<
40 () => Effect.Effect<
41 backupsearch.GetSearchJobOutput,
42 backupsearch.GetSearchJobError
43 >
44 >
45> {}
46
47export const GetSearchJob = Binding.Service<GetSearchJob>(
48 "AWS.BackupSearch.GetSearchJob",
49);