Skip to content

create_archive

create_archive(
    archive_name: ArchiveName,
    event_source_arn: Arn,
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    description: Optional[ArchiveDescription] = None,
    event_pattern: Optional[EventPattern] = None,
    retention_days: Optional[RetentionDays] = None,
) -> CreateArchiveResponse

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.

Parameters:

  • archive_name (ArchiveName) –

    The name for the archive to create.

  • event_source_arn (Arn) –

    The ARN of the event bus that sends events to the archive.

  • description (Optional[ArchiveDescription], default: None ) –

    A description for the archive.

  • event_pattern (Optional[EventPattern], default: None ) –

    An event pattern to use to filter events sent to the archive.

  • retention_days (Optional[RetentionDays], default: None ) –

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

Raises:

Source code in docs_src/capo_cloudwatch_events/_services/cloud_watch_events.py
def create_archive(
    self,
    archive_name: "capo_cloudwatch_events.types.archive_name.ArchiveName",
    event_source_arn: "capo_cloudwatch_events.types.arn.Arn",
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    description: Optional[
        "capo_cloudwatch_events.types.archive_description.ArchiveDescription"
    ] = None,
    event_pattern: Optional[
        "capo_cloudwatch_events.types.event_pattern.EventPattern"
    ] = None,
    retention_days: Optional[
        "capo_cloudwatch_events.types.retention_days.RetentionDays"
    ] = None,
) -> "capo_cloudwatch_events.types.create_archive_response.CreateArchiveResponse":
    """<p>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.</p>

    Args:
        archive_name: <p>The name for the archive to create.</p>
        event_source_arn: <p>The ARN of the event bus that sends events to the archive.</p>
        description: <p>A description for the archive.</p>
        event_pattern: <p>An event pattern to use to filter events sent to the archive.</p>
        retention_days: <p>The number of days to retain events for. Default value is 0. If set to 0, events are retained indefinitely</p>

    Raises:
        capo_cloudwatch_events.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_cloudwatch_events.errors.invalid_event_pattern_exception.InvalidEventPatternException: <p>The event pattern is not valid.</p>
        capo_cloudwatch_events.errors.limit_exceeded_exception.LimitExceededException: <p>The request failed because it attempted to create resource beyond the allowed service quota.</p>
        capo_cloudwatch_events.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource you are trying to create already exists.</p>
        capo_cloudwatch_events.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_cloudwatch_events.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_events.types.create_archive_request.CreateArchiveRequest]",
    ) -> OperationResponse[
        "capo_cloudwatch_events.types.create_archive_response.CreateArchiveResponse"
    ]:
        import capo_cloudwatch_events._operations.aws_events.create_archive

        output, http_response = (
            capo_cloudwatch_events._operations.aws_events.create_archive.create_archive(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateArchive")
    )
    input_: capo_cloudwatch_events.types.create_archive_request.CreateArchiveRequest = {
        "archive_name": archive_name,
        "event_source_arn": event_source_arn,
    }
    if description is not None:
        input_["description"] = description
    if event_pattern is not None:
        input_["event_pattern"] = event_pattern
    if retention_days is not None:
        input_["retention_days"] = retention_days

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output