sampleChannelData method

Future<SampleChannelDataResponse> sampleChannelData({
  1. required String channelName,
  2. DateTime? endTime,
  3. int? maxMessages,
  4. DateTime? startTime,
})

Retrieves a sample of messages from the specified channel ingested during the specified timeframe. Up to 10 messages can be retrieved.

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

Parameter channelName : The name of the channel whose message samples are retrieved.

Parameter endTime : The end of the time window from which sample messages are retrieved.

Parameter maxMessages : The number of sample messages to be retrieved. The limit is 10. The default is also 10.

Parameter startTime : The start of the time window from which sample messages are retrieved.

Implementation

Future<SampleChannelDataResponse> sampleChannelData({
  required String channelName,
  DateTime? endTime,
  int? maxMessages,
  DateTime? startTime,
}) async {
  ArgumentError.checkNotNull(channelName, 'channelName');
  _s.validateStringLength(
    'channelName',
    channelName,
    1,
    128,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxMessages',
    maxMessages,
    1,
    10,
  );
  final $query = <String, List<String>>{
    if (endTime != null) 'endTime': [_s.iso8601ToJson(endTime).toString()],
    if (maxMessages != null) 'maxMessages': [maxMessages.toString()],
    if (startTime != null)
      'startTime': [_s.iso8601ToJson(startTime).toString()],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/channels/${Uri.encodeComponent(channelName)}/sample',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return SampleChannelDataResponse.fromJson(response);
}