2828use Google \Cloud \Dlp \V2 \CloudStorageOptions ;
2929use Google \Cloud \Dlp \V2 \CloudStorageOptions_FileSet ;
3030use Google \Cloud \Dlp \V2 \StorageConfig ;
31+ use Google \Cloud \Dlp \V2 \StorageConfig_TimespanConfig ;
3132use Google \Cloud \Dlp \V2 \InfoType ;
3233use Google \Cloud \Dlp \V2 \Likelihood ;
3334use Google \Cloud \Dlp \V2 \InspectConfig_FindingLimits ;
4344 * @param string $description (Optional) A description for the trigger to be created
4445 * @param int $scanPeriod (Optional) How often to wait between scans, in days (minimum = 1 day)
4546 * @param int $maxFindings (Optional) The maximum number of findings to report per request (0 = server maximum)
47+ * @param bool $autoPopulateTimespan (Optional) Automatically limit scan to new content only
4648 */
4749
4850function create_trigger (
@@ -52,7 +54,8 @@ function create_trigger(
5254 $ displayName = '' ,
5355 $ description = '' ,
5456 $ scanPeriod = 1 ,
55- $ maxFindings = 0
57+ $ maxFindings = 0 ,
58+ $ autoPopulateTimespan = false
5659) {
5760 // Instantiate a client.
5861 $ dlp = new DlpServiceClient ();
@@ -95,8 +98,13 @@ function create_trigger(
9598 $ storageOptions = (new CloudStorageOptions ())
9699 ->setFileSet ($ fileSet );
97100
101+ // Auto-populate start and end times in order to scan new objects only.
102+ $ timespanConfig = (new StorageConfig_TimespanConfig ())
103+ ->setEnableAutoPopulationOfTimespanConfig ($ autoPopulateTimespan );
104+
98105 $ storageConfig = (new StorageConfig ())
99- ->setCloudStorageOptions ($ storageOptions );
106+ ->setCloudStorageOptions ($ storageOptions )
107+ ->setTimespanConfig ($ timespanConfig );
100108
101109 // Construct the jobConfig object
102110 $ jobConfig = (new InspectJobConfig ())
0 commit comments