Skip to content

Api reference

components.compliance.public.commands

create_gdpr_deletion_batch_for_data_bucket

create_gdpr_deletion_batch_for_data_bucket

create_gdpr_deletion_batch_for_data_bucket(
    bucket_type, dry_run=False
)

Create a GDPR deletion batch for a given data bucket.

Source code in components/compliance/public/commands/create_gdpr_deletion_batch_for_data_bucket.py
@compliance_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--bucket-type",
    type=click.Choice(ComplianceDataBucketType.get_values()),
    required=True,
    help="Type of data bucket for GDPR deletion batch",
)
def create_gdpr_deletion_batch_for_data_bucket(
    bucket_type: str, dry_run: bool = False
) -> None:
    """Create a GDPR deletion batch for a given data bucket."""
    bucket_type_enum = ComplianceDataBucketType(bucket_type)

    deletion_records = get_gdpr_deletion_records_to_batch_review(
        bucket_type=bucket_type_enum
    )
    if len(deletion_records) == 0:
        current_logger.info(
            f"No deletion records found for bucket type {bucket_type_enum}, stopping here"
        )
        return

    deletion_batch = create_gdpr_deletion_batch(
        bucket_type=bucket_type_enum,
        commit=not dry_run,
    )
    current_logger.info(
        f"Created GDPR deletion batch {deletion_batch.id} for bucket type {bucket_type_enum}"
    )

    current_logger.info(
        f"Assigning {len(deletion_records)} deletion records to batch {deletion_batch.id}"
    )

    for deletion_record in deletion_records:
        assign_deletion_record_to_batch(
            deletion_record_id=deletion_record.id,
            deletion_batch_id=deletion_batch.id,
            commit=not dry_run,
        )

create_gdpr_deletion_records_for_data_bucket

create_gdpr_deletion_records_for_data_bucket

create_gdpr_deletion_records_for_data_bucket(
    bucket_type, dry_run=False
)

Trigger the GDPR deletion process for a given bucket type, for each member targeted for deletion, we will create a GDPR deletion record

Source code in components/compliance/public/commands/create_gdpr_deletion_records_for_data_bucket.py
@compliance_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--bucket-type",
    type=click.Choice(ComplianceDataBucketType.get_values()),
    required=True,
    help="Type of data bucket for GDPR deletion records",
)
def create_gdpr_deletion_records_for_data_bucket(
    bucket_type: str, dry_run: bool = False
) -> None:
    """Trigger the GDPR deletion process for a given bucket type, for each member targeted for deletion, we will create a GDPR deletion record"""
    profiles_targeted_for_deletion = []

    # Convert string back to enum
    bucket_type_enum = ComplianceDataBucketType(bucket_type)

    # Get the methods to find the profile to delete for the given bucket type
    # This is a list of methods to call from each components within the app
    methods_to_find_profiles_to_delete = (
        get_callable_rules_to_get_profiles_to_record_deletion(
            bucket_type=bucket_type_enum
        )
    )

    # Call the methods above and get the return values in arrays and intersect these arrays into a single list where only the same ids are presents in all the arrays
    profiles_to_delete_for_each_method = [
        method_to_find_profiles_to_delete()
        for method_to_find_profiles_to_delete in methods_to_find_profiles_to_delete
    ]
    if profiles_to_delete_for_each_method:
        profiles_targeted_for_deletion = list(
            set.intersection(*map(set, profiles_to_delete_for_each_method))
        )

    current_logger.info(
        f"Found {len(profiles_targeted_for_deletion)} profiles targeted for deletion for bucket type {bucket_type_enum}"
    )
    for index, profile_id_to_delete in enumerate(profiles_targeted_for_deletion):
        current_logger.info(
            f"[{index}/{len(profiles_targeted_for_deletion)}] Creating GDPR deletion record for profile {profile_id_to_delete} for bucket type {bucket_type_enum}"
        )

        compliance_profile = get_or_create_compliance_profile(
            global_profile_id=profile_id_to_delete,
            commit=not dry_run,
        )

        create_gdpr_deletion_record(
            compliance_profile_id=compliance_profile.id,
            bucket_type=bucket_type_enum,
            commit=not dry_run,
        )

components.compliance.public.entities

ComplianceProfile dataclass

ComplianceProfile(
    id, global_profile_id, created_at, updated_at
)

Bases: DataClassJsonMixin

Entity representing a compliance profile model

created_at instance-attribute

created_at

global_profile_id instance-attribute

global_profile_id

id instance-attribute

id

updated_at instance-attribute

updated_at

GdprDeletionBatch dataclass

GdprDeletionBatch(
    id,
    bucket_type,
    deletion_records,
    reviewed_status,
    reviewed_at,
    reviewed_by,
    reviewed_reason,
    created_at,
    updated_at,
    records_count_for_list=0,
)

Bases: DataClassJsonMixin

Entity representing a GDPR deletion batch model

bucket_type instance-attribute

bucket_type

created_at instance-attribute

created_at

deletion_records instance-attribute

deletion_records

id instance-attribute

id

records_count_for_list class-attribute instance-attribute

records_count_for_list = 0

reviewed_at instance-attribute

reviewed_at

reviewed_by instance-attribute

reviewed_by

reviewed_reason instance-attribute

reviewed_reason

reviewed_status instance-attribute

reviewed_status

updated_at instance-attribute

updated_at

GdprDeletionRecord dataclass

GdprDeletionRecord(
    id,
    compliance_profile_id,
    compliance_profile,
    bucket_type,
    deletion_batch_id,
    deletion_scheduled_at,
    deletion_applied_at,
    created_at,
    updated_at,
)

Bases: DataClassJsonMixin

Entity representing a GDPR deletion record model

bucket_type instance-attribute

bucket_type

compliance_profile instance-attribute

compliance_profile

compliance_profile_id instance-attribute

compliance_profile_id

created_at instance-attribute

created_at

deletion_applied_at instance-attribute

deletion_applied_at

deletion_batch_id instance-attribute

deletion_batch_id

deletion_scheduled_at instance-attribute

deletion_scheduled_at

id instance-attribute

id

updated_at instance-attribute

updated_at

components.compliance.public.enums

ComplianceDataBucketType

Bases: AlanBaseEnum

Type of data bucket to be considered for GDPR compliance deletion process

health_claims class-attribute instance-attribute

health_claims = 'health_claims'

health_services class-attribute instance-attribute

health_services = 'health_services'

medical_data class-attribute instance-attribute

medical_data = 'medical_data'

prevoyance_claims class-attribute instance-attribute

prevoyance_claims = 'prevoyance_claims'

GdprDeletionBatchStatus

Bases: AlanBaseEnum

Status of a GDPR compliance batch

accepted class-attribute instance-attribute

accepted = 'accepted'

pending class-attribute instance-attribute

pending = 'pending'

rejected class-attribute instance-attribute

rejected = 'rejected'