createArchive method

Future<CreateArchiveResponse> createArchive({
  1. required String archiveName,
  2. required String eventSourceArn,
  3. String? description,
  4. String? eventPattern,
  5. int? retentionDays,
})

Creates an archive of events with the specified settings. When you create an archive, incoming events might not immediately start being sent to the archive. Allow a short period of time for changes to take effect. If you do not specify a pattern to filter events sent to the archive, all events are sent to the archive except replayed events. Replayed events are not sent to an archive.

May throw ConcurrentModificationException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw InternalException. May throw LimitExceededException. May throw InvalidEventPatternException.

Parameter archiveName : The name for the archive to create.

Parameter eventSourceArn : The ARN of the event source associated with the archive.

Parameter description : A description for the archive.

Parameter eventPattern : An event pattern to use to filter events sent to the archive.

Parameter retentionDays : The number of days to retain events for. Default value is 0. If set to 0, events are retained indefinitely

Implementation

Future<CreateArchiveResponse> createArchive({
  required String archiveName,
  required String eventSourceArn,
  String? description,
  String? eventPattern,
  int? retentionDays,
}) async {
  ArgumentError.checkNotNull(archiveName, 'archiveName');
  _s.validateStringLength(
    'archiveName',
    archiveName,
    1,
    48,
    isRequired: true,
  );
  ArgumentError.checkNotNull(eventSourceArn, 'eventSourceArn');
  _s.validateStringLength(
    'eventSourceArn',
    eventSourceArn,
    1,
    1600,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    512,
  );
  _s.validateNumRange(
    'retentionDays',
    retentionDays,
    0,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.CreateArchive'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ArchiveName': archiveName,
      'EventSourceArn': eventSourceArn,
      if (description != null) 'Description': description,
      if (eventPattern != null) 'EventPattern': eventPattern,
      if (retentionDays != null) 'RetentionDays': retentionDays,
    },
  );

  return CreateArchiveResponse.fromJson(jsonResponse.body);
}