| 1 | import type * as forecast from "@distilled.cloud/aws/forecast"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Runtime binding for `forecast:CreateWhatIfForecast` — create a scenario |
| 7 | * forecast under a what-if analysis, transforming the baseline time series |
| 8 | * (or replacing it from S3) so the outcome can be compared with |
| 9 | * {@link QueryWhatIfForecast}. |
| 10 | * |
| 11 | * What-if forecast ARNs are created at runtime, so the binding takes no |
| 12 | * arguments and grants `forecast:CreateWhatIfForecast` on `*`, plus |
| 13 | * `iam:PassRole` (conditioned to `forecast.amazonaws.com`) for the |
| 14 | * replacement-data-source role. Provide the implementation with |
| 15 | * `Effect.provide(AWS.Forecast.CreateWhatIfForecastHttp)`. |
| 16 | * |
| 17 | * ### What-If Scenarios |
| 18 | * **Example:** Create a Price-Drop Scenario |
| 19 | * ```typescript |
| 20 | * // init |
| 21 | * const createWhatIfForecast = yield* AWS.Forecast.CreateWhatIfForecast(); |
| 22 | * |
| 23 | * // runtime |
| 24 | * const scenario = yield* createWhatIfForecast({ |
| 25 | * WhatIfForecastName: "price_drop_10pct", |
| 26 | * WhatIfAnalysisArn: analysisArn, |
| 27 | * TimeSeriesTransformations: [ |
| 28 | * { |
| 29 | * Action: { |
| 30 | * AttributeName: "price", |
| 31 | * Operation: "MULTIPLY", |
| 32 | * Value: 0.9, |
| 33 | * }, |
| 34 | * }, |
| 35 | * ], |
| 36 | * }); |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface CreateWhatIfForecast extends Binding.Service< |
| 42 | CreateWhatIfForecast, |
| 43 | "AWS.Forecast.CreateWhatIfForecast", |
| 44 | () => Effect.Effect< |
| 45 | ( |
| 46 | request: forecast.CreateWhatIfForecastRequest, |
| 47 | ) => Effect.Effect< |
| 48 | forecast.CreateWhatIfForecastResponse, |
| 49 | forecast.CreateWhatIfForecastError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | export const CreateWhatIfForecast = Binding.Service<CreateWhatIfForecast>( |
| 54 | "AWS.Forecast.CreateWhatIfForecast", |
| 55 | ); |