listMetricValues method

Future<ListMetricValuesResponse> listMetricValues({
  1. required DateTime endTime,
  2. required String metricName,
  3. required DateTime startTime,
  4. required String thingName,
  5. String? dimensionName,
  6. DimensionValueOperator? dimensionValueOperator,
  7. int? maxResults,
  8. String? nextToken,
})

Lists the values reported for an IoT Device Defender metric (device-side metric, cloud-side metric, or custom metric) by the given thing during the specified time period.

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

Parameter endTime : The end of the time period for which metric values are returned.

Parameter metricName : The name of the security profile metric for which values are returned.

Parameter startTime : The start of the time period for which metric values are returned.

Parameter thingName : The name of the thing for which security profile metric values are returned.

Parameter dimensionName : The dimension name.

Parameter dimensionValueOperator : The dimension value operator.

Parameter maxResults : The maximum number of results to return at one time.

Parameter nextToken : The token for the next set of results.

Implementation

Future<ListMetricValuesResponse> listMetricValues({
  required DateTime endTime,
  required String metricName,
  required DateTime startTime,
  required String thingName,
  String? dimensionName,
  DimensionValueOperator? dimensionValueOperator,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    250,
  );
  final $query = <String, List<String>>{
    'endTime': [_s.iso8601ToJson(endTime).toString()],
    'metricName': [metricName],
    'startTime': [_s.iso8601ToJson(startTime).toString()],
    'thingName': [thingName],
    if (dimensionName != null) 'dimensionName': [dimensionName],
    if (dimensionValueOperator != null)
      'dimensionValueOperator': [dimensionValueOperator.value],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/metric-values',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListMetricValuesResponse.fromJson(response);
}