31
31
import com .google .privacy .dlp .v2 .ProjectName ;
32
32
import com .google .privacy .dlp .v2 .Schedule ;
33
33
import com .google .privacy .dlp .v2 .StorageConfig ;
34
+ import com .google .privacy .dlp .v2 .StorageConfig .TimespanConfig ;
34
35
import com .google .protobuf .Duration ;
35
36
import java .util .ArrayList ;
36
37
import java .util .List ;
@@ -52,6 +53,7 @@ public class Triggers {
52
53
* @param triggerId (Optional) name of the trigger to be created
53
54
* @param displayName (Optional) display name for the trigger to be created
54
55
* @param description (Optional) description for the trigger to be created
56
+ * @param autoPopulateTimespan If true, limits scans to new content only.
55
57
* @param scanPeriod How often to wait between scans, in days (minimum = 1 day)
56
58
* @param infoTypes infoTypes of information to match eg. InfoType.PHONE_NUMBER,
57
59
* InfoType.EMAIL_ADDRESS
@@ -65,6 +67,7 @@ private static void createTrigger(
65
67
String description ,
66
68
String bucketName ,
67
69
String fileName ,
70
+ boolean autoPopulateTimespan ,
68
71
int scanPeriod ,
69
72
List <InfoType > infoTypes ,
70
73
Likelihood minLikelihood ,
@@ -82,8 +85,13 @@ private static void createTrigger(
82
85
CloudStorageOptions .FileSet .newBuilder ()
83
86
.setUrl ("gs://" + bucketName + "/" + fileName ))
84
87
.build ();
88
+
89
+ TimespanConfig timespanConfig = TimespanConfig .newBuilder ()
90
+ .setEnableAutoPopulationOfTimespanConfig (autoPopulateTimespan ).build ();
91
+
85
92
StorageConfig storageConfig =
86
- StorageConfig .newBuilder ().setCloudStorageOptions (cloudStorageOptions ).build ();
93
+ StorageConfig .newBuilder ().setCloudStorageOptions (cloudStorageOptions )
94
+ .setTimespanConfig (timespanConfig ).build ();
87
95
88
96
InspectConfig .FindingLimits findingLimits =
89
97
InspectConfig .FindingLimits .newBuilder ().setMaxFindingsPerRequest (maxFindings ).build ();
@@ -216,6 +224,10 @@ public static void main(String[] args) throws Exception {
216
224
Option gcsFileNameOption = Option .builder ("fileName" ).hasArg (true ).required (false ).build ();
217
225
commandLineOptions .addOption (gcsFileNameOption );
218
226
227
+ Option autoPopulateTimespanOption = Option .builder ("autoPopulateTimespan" ).required (false )
228
+ .build ();
229
+ commandLineOptions .addOption (autoPopulateTimespanOption );
230
+
219
231
Option minLikelihoodOption =
220
232
Option .builder ("minLikelihood" ).hasArg (true ).required (false ).build ();
221
233
@@ -268,6 +280,8 @@ public static void main(String[] args) throws Exception {
268
280
String description = cmd .getOptionValue (descriptionOption .getOpt (), "" );
269
281
String bucketName = cmd .getOptionValue (bucketNameOption .getOpt ());
270
282
String fileName = cmd .getOptionValue (gcsFileNameOption .getOpt ());
283
+ boolean autoPopulateTimespan = Boolean
284
+ .valueOf (cmd .getOptionValue (autoPopulateTimespanOption .getOpt ()));
271
285
int scanPeriod = Integer .valueOf (cmd .getOptionValue (scanPeriodOption .getOpt ()));
272
286
List <InfoType > infoTypesList = new ArrayList <>();
273
287
if (cmd .hasOption (infoTypesOption .getOpt ())) {
@@ -283,6 +297,7 @@ public static void main(String[] args) throws Exception {
283
297
description ,
284
298
bucketName ,
285
299
fileName ,
300
+ autoPopulateTimespan ,
286
301
scanPeriod ,
287
302
infoTypesList ,
288
303
minLikelihood ,
0 commit comments