| 1 | import type * as sitewise from "@distilled.cloud/aws/iotsitewise"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Asset } from "./Asset.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Request for {@link GetInterpolatedAssetPropertyValues}. The bound asset's |
| 8 | * id is injected automatically. |
| 9 | * |
| 10 | * The `startTimeInSeconds` / `endTimeInSeconds` / `intervalInSeconds` |
| 11 | * fields keep their wire names: they are epoch timestamps and an interval |
| 12 | * that are part of this operation's request shape, passed through verbatim. |
| 13 | */ |
| 14 | export interface GetInterpolatedAssetPropertyValuesRequest extends Omit< |
| 15 | sitewise.GetInterpolatedAssetPropertyValuesRequest, |
| 16 | "assetId" |
| 17 | > {} |
| 18 | |
| 19 | /** |
| 20 | * Runtime binding for `iotsitewise:GetInterpolatedAssetPropertyValues` — |
| 21 | * compute interpolated values (`LINEAR_INTERPOLATION` or |
| 22 | * `LOCF_INTERPOLATION`) of one property of the bound asset at a fixed |
| 23 | * interval from a deployed Lambda or Task. |
| 24 | * |
| 25 | * ### Reading Interpolated Values |
| 26 | * Provide the `GetInterpolatedAssetPropertyValuesHttp` implementation layer |
| 27 | * on the Function effect, bind the asset in the init phase, then call the |
| 28 | * returned client at runtime. |
| 29 | * |
| 30 | * **Example:** Interpolate at 1-Minute Intervals |
| 31 | * ```typescript |
| 32 | * // init |
| 33 | * const getInterpolated = |
| 34 | * yield* AWS.IoTSiteWise.GetInterpolatedAssetPropertyValues(asset); |
| 35 | * |
| 36 | * // runtime |
| 37 | * const now = yield* Effect.sync(() => Math.floor(Date.now() / 1000)); |
| 38 | * const { interpolatedAssetPropertyValues } = yield* getInterpolated({ |
| 39 | * propertyId, |
| 40 | * startTimeInSeconds: now - 3600, |
| 41 | * endTimeInSeconds: now, |
| 42 | * intervalInSeconds: 60, |
| 43 | * quality: "GOOD", |
| 44 | * type: "LINEAR_INTERPOLATION", |
| 45 | * }); |
| 46 | * // on the Function effect: |
| 47 | * // .pipe(Effect.provide(AWS.IoTSiteWise.GetInterpolatedAssetPropertyValuesHttp)) |
| 48 | * ``` |
| 49 | * |
| 50 | * @binding |
| 51 | */ |
| 52 | export interface GetInterpolatedAssetPropertyValues extends Binding.Service< |
| 53 | GetInterpolatedAssetPropertyValues, |
| 54 | "AWS.IoTSiteWise.GetInterpolatedAssetPropertyValues", |
| 55 | ( |
| 56 | asset: Asset, |
| 57 | ) => Effect.Effect< |
| 58 | ( |
| 59 | request: GetInterpolatedAssetPropertyValuesRequest, |
| 60 | ) => Effect.Effect< |
| 61 | sitewise.GetInterpolatedAssetPropertyValuesResponse, |
| 62 | sitewise.GetInterpolatedAssetPropertyValuesError |
| 63 | > |
| 64 | > |
| 65 | > {} |
| 66 | export const GetInterpolatedAssetPropertyValues = |
| 67 | Binding.Service<GetInterpolatedAssetPropertyValues>( |
| 68 | "AWS.IoTSiteWise.GetInterpolatedAssetPropertyValues", |
| 69 | ); |