-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): query for describing unmodeled data stream
- Loading branch information
1 parent
a93613a
commit 2d1226d
Showing
5 changed files
with
95 additions
and
27 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/dashboard/src/components/csvDownloadButton/getDescribedTimeSeries.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { DescribeTimeSeriesCommand, IoTSiteWiseClient } from '@aws-sdk/client-iotsitewise'; | ||
import invariant from 'tiny-invariant'; | ||
|
||
const isEnabled = (input?: string): input is string => Boolean(input); | ||
|
||
export const getDescribedTimeSeries = async ({ | ||
client, | ||
assetId, | ||
propertyId, | ||
alias, | ||
}: { | ||
client: IoTSiteWiseClient; | ||
assetId?: string; | ||
propertyId?: string; | ||
alias?: string; | ||
}) => { | ||
invariant( | ||
isEnabled(alias) || (isEnabled(assetId) && isEnabled(propertyId)), | ||
'Expected alias or assetID+propertyID to be defined as required by the enabled flag.' | ||
); | ||
|
||
const params = { assetId, propertyId, alias }; | ||
const command = new DescribeTimeSeriesCommand(params); | ||
|
||
try { | ||
const data = await client.send(command); | ||
return { data, isSuccess: true }; | ||
} catch (error) { | ||
console.error(`Failed to get described time series. Error: ${error}`); | ||
console.info('Request input:'); | ||
console.table(params); | ||
|
||
throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters