Пример #1
0
 def test_create_job_trigger(self, mock_hook):
     mock_hook.return_value.create_job_trigger.return_value = {}
     operator = CloudDLPCreateJobTriggerOperator(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.create_job_trigger.assert_called_once_with(
         project_id=PROJECT_ID,
         job_trigger=None,
         trigger_id=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Пример #2
0
    }],
    "status":
    "HEALTHY",
}

TRIGGER_ID = "example_trigger"

with models.DAG("example_gcp_dlp_job",
                schedule_interval=None,
                start_date=days_ago(1),
                tags=[
                    "example", "dlp_job"
                ]) as dag3:  # [START howto_operator_dlp_create_job_trigger]
    create_trigger = CloudDLPCreateJobTriggerOperator(
        project_id=GCP_PROJECT,
        job_trigger=JOB_TRIGGER,
        trigger_id=TRIGGER_ID,
        task_id="create_trigger",
    )
    # [END howto_operator_dlp_create_job_trigger]

    JOB_TRIGGER["triggers"] = [{
        "schedule": {
            "recurrence_period_duration": {
                "seconds": 2 * 60 * 60 * 24
            }
        }
    }]

    # [START howto_operator_dlp_update_job_trigger]
    update_trigger = CloudDLPUpdateJobTriggerOperator(
        project_id=GCP_PROJECT,