| 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 GetAssetPropertyAggregates}. The bound asset's id is |
| 8 | * injected automatically. |
| 9 | */ |
| 10 | export interface GetAssetPropertyAggregatesRequest extends Omit< |
| 11 | sitewise.GetAssetPropertyAggregatesRequest, |
| 12 | "assetId" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `iotsitewise:GetAssetPropertyAggregates` — read |
| 17 | * pre-computed aggregates (`AVERAGE`, `MINIMUM`, `MAXIMUM`, `SUM`, `COUNT`, |
| 18 | * `STANDARD_DEVIATION`) of one property of the bound asset over a time |
| 19 | * range at a fixed resolution from a deployed Lambda or Task. |
| 20 | * |
| 21 | * ### Reading Aggregates |
| 22 | * Provide the `GetAssetPropertyAggregatesHttp` implementation layer on the |
| 23 | * Function effect, bind the asset in the init phase, then call the returned |
| 24 | * client at runtime. |
| 25 | * |
| 26 | * **Example:** Hourly Average over the Last Day |
| 27 | * ```typescript |
| 28 | * // init |
| 29 | * const getAggregates = yield* AWS.IoTSiteWise.GetAssetPropertyAggregates(asset); |
| 30 | * |
| 31 | * // runtime |
| 32 | * const now = yield* Effect.sync(() => new Date()); |
| 33 | * const { aggregatedValues } = yield* getAggregates({ |
| 34 | * propertyId, |
| 35 | * aggregateTypes: ["AVERAGE"], |
| 36 | * resolution: "1h", |
| 37 | * startDate: new Date(now.getTime() - 86_400_000), |
| 38 | * endDate: now, |
| 39 | * }); |
| 40 | * // on the Function effect: |
| 41 | * // .pipe(Effect.provide(AWS.IoTSiteWise.GetAssetPropertyAggregatesHttp)) |
| 42 | * ``` |
| 43 | * |
| 44 | * @binding |
| 45 | */ |
| 46 | export interface GetAssetPropertyAggregates extends Binding.Service< |
| 47 | GetAssetPropertyAggregates, |
| 48 | "AWS.IoTSiteWise.GetAssetPropertyAggregates", |
| 49 | ( |
| 50 | asset: Asset, |
| 51 | ) => Effect.Effect< |
| 52 | ( |
| 53 | request: GetAssetPropertyAggregatesRequest, |
| 54 | ) => Effect.Effect< |
| 55 | sitewise.GetAssetPropertyAggregatesResponse, |
| 56 | sitewise.GetAssetPropertyAggregatesError |
| 57 | > |
| 58 | > |
| 59 | > {} |
| 60 | export const GetAssetPropertyAggregates = |
| 61 | Binding.Service<GetAssetPropertyAggregates>( |
| 62 | "AWS.IoTSiteWise.GetAssetPropertyAggregates", |
| 63 | ); |