def create_export_and_wait_for_completion()

in pyqldbsamples/export_journal.py [0:0]


def create_export_and_wait_for_completion(name, bucket, prefix, encryption_config, role_arn=None):
    """
    Request QLDB to export the contents of the journal for the given time period and S3 configuration. Before calling
    this function the S3 bucket should be created, see
    :py:class:`pyqldbsamples.export_journal.create_s3_bucket_if_not_exists`

    :type name: str
    :param name: Name of the ledger to create a journal export for.

    :type bucket: str
    :param bucket: S3 bucket to write the data to.

    :type prefix: str
    :param prefix: S3 prefix to be prefixed to the files being written.

    :type encryption_config: dict
    :param encryption_config: Encryption configuration for S3.

    :type role_arn: str
    :param role_arn: The IAM role ARN to be used when exporting the journal.

    :rtype: dict
    :return: The result of the request.
    """
    if role_arn is None:
        role_arn = create_export_role(EXPORT_ROLE_NAME, encryption_config.get('KmsKeyArn'), ROLE_POLICY_NAME, bucket)
    try:
        start_time = datetime.utcnow() - timedelta(minutes=JOURNAL_EXPORT_TIME_WINDOW_MINUTES)
        end_time = datetime.utcnow()

        result = create_export(name, start_time, end_time, bucket, prefix, encryption_config, role_arn)
        wait_for_export_to_complete(name, result.get('ExportId'))
        logger.info('JournalS3Export for exportId {} is completed.'.format(result.get('ExportId')))
        return result
    except Exception as e:
        logger.exception('Unable to create an export!')
        raise e