| 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 | * One entry of a {@link BatchPutAssetPropertyValue} request. The bound |
| 8 | * asset's id is injected automatically unless the entry targets a data |
| 9 | * stream by `propertyAlias`. |
| 10 | */ |
| 11 | export interface PutAssetPropertyValueEntry extends Omit< |
| 12 | sitewise.PutAssetPropertyValueEntry, |
| 13 | "assetId" |
| 14 | > {} |
| 15 | |
| 16 | /** |
| 17 | * Request for {@link BatchPutAssetPropertyValue}. |
| 18 | */ |
| 19 | export interface BatchPutAssetPropertyValueRequest { |
| 20 | /** |
| 21 | * Whether to continue processing the remaining entries when one entry |
| 22 | * fails. |
| 23 | */ |
| 24 | enablePartialEntryProcessing?: boolean; |
| 25 | /** |
| 26 | * Up to 10 entries, each carrying up to 10 timestamp-quality-value (TQV) |
| 27 | * data points for one property of the bound asset. |
| 28 | */ |
| 29 | entries: PutAssetPropertyValueEntry[]; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Runtime binding for `iotsitewise:BatchPutAssetPropertyValue` — ingest |
| 34 | * timestamped property values (measurements) into the bound asset's data |
| 35 | * streams from a deployed Lambda or Task. |
| 36 | * |
| 37 | * ### Ingesting Property Values |
| 38 | * Provide the `BatchPutAssetPropertyValueHttp` implementation layer on the |
| 39 | * Function effect, bind the asset in the init phase, then call the returned |
| 40 | * client at runtime. The binding grants |
| 41 | * `iotsitewise:BatchPutAssetPropertyValue` on the asset and injects its id |
| 42 | * into every entry automatically. |
| 43 | * |
| 44 | * **Example:** Ingest a Temperature Reading |
| 45 | * ```typescript |
| 46 | * // init |
| 47 | * const asset = yield* AWS.IoTSiteWise.Asset("Pump1", { |
| 48 | * assetModelId: model.assetModelId, |
| 49 | * }); |
| 50 | * const putValues = yield* AWS.IoTSiteWise.BatchPutAssetPropertyValue(asset); |
| 51 | * |
| 52 | * // runtime |
| 53 | * const now = yield* Effect.sync(() => Math.floor(Date.now() / 1000)); |
| 54 | * const { errorEntries } = yield* putValues({ |
| 55 | * entries: [ |
| 56 | * { |
| 57 | * entryId: "temp-1", |
| 58 | * propertyId, |
| 59 | * propertyValues: [ |
| 60 | * { |
| 61 | * value: { doubleValue: 23.5 }, |
| 62 | * timestamp: { timeInSeconds: now }, |
| 63 | * quality: "GOOD", |
| 64 | * }, |
| 65 | * ], |
| 66 | * }, |
| 67 | * ], |
| 68 | * }); |
| 69 | * // on the Function effect: |
| 70 | * // .pipe(Effect.provide(AWS.IoTSiteWise.BatchPutAssetPropertyValueHttp)) |
| 71 | * ``` |
| 72 | * |
| 73 | * @binding |
| 74 | */ |
| 75 | export interface BatchPutAssetPropertyValue extends Binding.Service< |
| 76 | BatchPutAssetPropertyValue, |
| 77 | "AWS.IoTSiteWise.BatchPutAssetPropertyValue", |
| 78 | ( |
| 79 | asset: Asset, |
| 80 | ) => Effect.Effect< |
| 81 | ( |
| 82 | request: BatchPutAssetPropertyValueRequest, |
| 83 | ) => Effect.Effect< |
| 84 | sitewise.BatchPutAssetPropertyValueResponse, |
| 85 | sitewise.BatchPutAssetPropertyValueError |
| 86 | > |
| 87 | > |
| 88 | > {} |
| 89 | export const BatchPutAssetPropertyValue = |
| 90 | Binding.Service<BatchPutAssetPropertyValue>( |
| 91 | "AWS.IoTSiteWise.BatchPutAssetPropertyValue", |
| 92 | ); |