getAssetPropertyAggregates method

Future<GetAssetPropertyAggregatesResponse> getAssetPropertyAggregates({
  1. required List<AggregateType> aggregateTypes,
  2. required DateTime endDate,
  3. required String resolution,
  4. required DateTime startDate,
  5. String? assetId,
  6. int? maxResults,
  7. String? nextToken,
  8. String? propertyAlias,
  9. String? propertyId,
  10. List<Quality>? qualities,
  11. TimeOrdering? timeOrdering,
})

Gets aggregated values for an asset property. For more information, see Querying aggregates in the IoT SiteWise User Guide.

To identify an asset property, you must specify one of the following:

  • The assetId and propertyId of an asset property.
  • A propertyAlias, which is a data stream alias (for example, /company/windfarm/3/turbine/7/temperature). To define an asset property's alias, see UpdateAssetProperty.

May throw InternalFailureException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException.

Parameter aggregateTypes : The data aggregating function.

Parameter endDate : The inclusive end of the range from which to query historical data, expressed in seconds in Unix epoch time.

Parameter resolution : The time interval over which to aggregate data.

Parameter startDate : The exclusive start of the range from which to query historical data, expressed in seconds in Unix epoch time.

Parameter assetId : The ID of the asset, in UUID format.

Parameter maxResults : The maximum number of results to return for each paginated request. A result set is returned in the two cases, whichever occurs first.

  • The size of the result set is equal to 1 MB.
  • The number of data points in the result set is equal to the value of maxResults. The maximum value of maxResults is 2500.

Parameter nextToken : The token to be used for the next set of paginated results.

Parameter propertyAlias : The alias that identifies the property, such as an OPC-UA server data stream path (for example, /company/windfarm/3/turbine/7/temperature). For more information, see Mapping industrial data streams to asset properties in the IoT SiteWise User Guide.

Parameter propertyId : The ID of the asset property, in UUID format.

Parameter qualities : The quality by which to filter asset data.

Parameter timeOrdering : The chronological sorting order of the requested information.

Default: ASCENDING

Implementation

Future<GetAssetPropertyAggregatesResponse> getAssetPropertyAggregates({
  required List<AggregateType> aggregateTypes,
  required DateTime endDate,
  required String resolution,
  required DateTime startDate,
  String? assetId,
  int? maxResults,
  String? nextToken,
  String? propertyAlias,
  String? propertyId,
  List<Quality>? qualities,
  TimeOrdering? timeOrdering,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1152921504606846976,
  );
  final $query = <String, List<String>>{
    'aggregateTypes': aggregateTypes.map((e) => e.value).toList(),
    'endDate': [_s.iso8601ToJson(endDate).toString()],
    'resolution': [resolution],
    'startDate': [_s.iso8601ToJson(startDate).toString()],
    if (assetId != null) 'assetId': [assetId],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
    if (propertyAlias != null) 'propertyAlias': [propertyAlias],
    if (propertyId != null) 'propertyId': [propertyId],
    if (qualities != null)
      'qualities': qualities.map((e) => e.value).toList(),
    if (timeOrdering != null) 'timeOrdering': [timeOrdering.value],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/properties/aggregates',
    queryParams: $query,
    hostPrefix: 'data.',
    exceptionFnMap: _exceptionFns,
  );
  return GetAssetPropertyAggregatesResponse.fromJson(response);
}