Example #1
0
 def test_deidentify_content(self, mock_hook):
     mock_hook.return_value.deidentify_content.return_value = {}
     operator = CloudDLPDeidentifyContentOperator(project_id=PROJECT_ID,
                                                  task_id="id")
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.deidentify_content.assert_called_once_with(
         project_id=PROJECT_ID,
         deidentify_config=None,
         inspect_config=None,
         item=None,
         inspect_template_name=None,
         deidentify_template_name=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Example #2
0
    "info_type_transformations": {
        "transformations": [{
            "primitive_transformation": {
                "replace_config": {
                    "new_value": {
                        "string_value": "[deidentified_number]"
                    }
                }
            }
        }]
    }
}
# [END dlp_deidentify_config_example]

with models.DAG(
        "example_gcp_dlp_deidentify_content",
        schedule_interval='@once',
        start_date=START_DATE,
        catchup=False,
        tags=["example", "dlp", "deidentify"],
) as dag4:
    # [START _howto_operator_dlp_deidentify_content]
    deidentify_content = CloudDLPDeidentifyContentOperator(
        project_id=GCP_PROJECT,
        item=ITEM,
        deidentify_config=DEIDENTIFY_CONFIG,
        inspect_config=INSPECT_CONFIG,
        task_id="deidentify_content",
    )
    # [END _howto_operator_dlp_deidentify_content]