updateDataRetention method

Future<void> updateDataRetention({
  1. required String currentVersion,
  2. required int dataRetentionChangeInHours,
  3. required UpdateDataRetentionOperation operation,
  4. String? streamARN,
  5. String? streamName,
})

Increases or decreases the stream's data retention period by the value that you specify. To indicate whether you want to increase or decrease the data retention period, specify the Operation parameter in the request body. In the request, you must specify either the StreamName or the StreamARN. This operation requires permission for the KinesisVideo:UpdateDataRetention action.

Changing the data retention period affects the data in the stream as follows:

  • If the data retention period is increased, existing data is retained for the new retention period. For example, if the data retention period is increased from one hour to seven hours, all existing data is retained for seven hours.
  • If the data retention period is decreased, existing data is retained for the new retention period. For example, if the data retention period is decreased from seven hours to one hour, all existing data is retained for one hour, and any data older than one hour is deleted immediately.

May throw ClientLimitExceededException. May throw InvalidArgumentException. May throw ResourceNotFoundException. May throw ResourceInUseException. May throw NotAuthorizedException. May throw VersionMismatchException.

Parameter currentVersion : The version of the stream whose retention period you want to change. To get the version, call either the DescribeStream or the ListStreams API.

Parameter dataRetentionChangeInHours : The retention period, in hours. The value you specify replaces the current value. The maximum value for this parameter is 87600 (ten years).

Parameter operation : Indicates whether you want to increase or decrease the retention period.

Parameter streamARN : The Amazon Resource Name (ARN) of the stream whose retention period you want to change.

Parameter streamName : The name of the stream whose retention period you want to change.

Implementation

Future<void> updateDataRetention({
  required String currentVersion,
  required int dataRetentionChangeInHours,
  required UpdateDataRetentionOperation operation,
  String? streamARN,
  String? streamName,
}) async {
  ArgumentError.checkNotNull(currentVersion, 'currentVersion');
  _s.validateStringLength(
    'currentVersion',
    currentVersion,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(
      dataRetentionChangeInHours, 'dataRetentionChangeInHours');
  _s.validateNumRange(
    'dataRetentionChangeInHours',
    dataRetentionChangeInHours,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(operation, 'operation');
  _s.validateStringLength(
    'streamARN',
    streamARN,
    1,
    1024,
  );
  _s.validateStringLength(
    'streamName',
    streamName,
    1,
    256,
  );
  final $payload = <String, dynamic>{
    'CurrentVersion': currentVersion,
    'DataRetentionChangeInHours': dataRetentionChangeInHours,
    'Operation': operation.toValue(),
    if (streamARN != null) 'StreamARN': streamARN,
    if (streamName != null) 'StreamName': streamName,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/updateDataRetention',
    exceptionFnMap: _exceptionFns,
  );
}