3131import com .google .privacy .dlp .v2 .ProjectName ;
3232import com .google .privacy .dlp .v2 .Schedule ;
3333import com .google .privacy .dlp .v2 .StorageConfig ;
34+ import com .google .privacy .dlp .v2 .StorageConfig .TimespanConfig ;
3435import com .google .protobuf .Duration ;
3536import java .util .ArrayList ;
3637import java .util .List ;
@@ -52,6 +53,7 @@ public class Triggers {
5253 * @param triggerId (Optional) name of the trigger to be created
5354 * @param displayName (Optional) display name for the trigger to be created
5455 * @param description (Optional) description for the trigger to be created
56+ * @param autoPopulateTimespan If true, limits scans to new content only.
5557 * @param scanPeriod How often to wait between scans, in days (minimum = 1 day)
5658 * @param infoTypes infoTypes of information to match eg. InfoType.PHONE_NUMBER,
5759 * InfoType.EMAIL_ADDRESS
@@ -65,6 +67,7 @@ private static void createTrigger(
6567 String description ,
6668 String bucketName ,
6769 String fileName ,
70+ boolean autoPopulateTimespan ,
6871 int scanPeriod ,
6972 List <InfoType > infoTypes ,
7073 Likelihood minLikelihood ,
@@ -82,8 +85,13 @@ private static void createTrigger(
8285 CloudStorageOptions .FileSet .newBuilder ()
8386 .setUrl ("gs://" + bucketName + "/" + fileName ))
8487 .build ();
88+
89+ TimespanConfig timespanConfig = TimespanConfig .newBuilder ()
90+ .setEnableAutoPopulationOfTimespanConfig (autoPopulateTimespan ).build ();
91+
8592 StorageConfig storageConfig =
86- StorageConfig .newBuilder ().setCloudStorageOptions (cloudStorageOptions ).build ();
93+ StorageConfig .newBuilder ().setCloudStorageOptions (cloudStorageOptions )
94+ .setTimespanConfig (timespanConfig ).build ();
8795
8896 InspectConfig .FindingLimits findingLimits =
8997 InspectConfig .FindingLimits .newBuilder ().setMaxFindingsPerRequest (maxFindings ).build ();
@@ -216,6 +224,10 @@ public static void main(String[] args) throws Exception {
216224 Option gcsFileNameOption = Option .builder ("fileName" ).hasArg (true ).required (false ).build ();
217225 commandLineOptions .addOption (gcsFileNameOption );
218226
227+ Option autoPopulateTimespanOption = Option .builder ("autoPopulateTimespan" ).required (false )
228+ .build ();
229+ commandLineOptions .addOption (autoPopulateTimespanOption );
230+
219231 Option minLikelihoodOption =
220232 Option .builder ("minLikelihood" ).hasArg (true ).required (false ).build ();
221233
@@ -268,6 +280,8 @@ public static void main(String[] args) throws Exception {
268280 String description = cmd .getOptionValue (descriptionOption .getOpt (), "" );
269281 String bucketName = cmd .getOptionValue (bucketNameOption .getOpt ());
270282 String fileName = cmd .getOptionValue (gcsFileNameOption .getOpt ());
283+ boolean autoPopulateTimespan = Boolean
284+ .valueOf (cmd .getOptionValue (autoPopulateTimespanOption .getOpt ()));
271285 int scanPeriod = Integer .valueOf (cmd .getOptionValue (scanPeriodOption .getOpt ()));
272286 List <InfoType > infoTypesList = new ArrayList <>();
273287 if (cmd .hasOption (infoTypesOption .getOpt ())) {
@@ -283,6 +297,7 @@ public static void main(String[] args) throws Exception {
283297 description ,
284298 bucketName ,
285299 fileName ,
300+ autoPopulateTimespan ,
286301 scanPeriod ,
287302 infoTypesList ,
288303 minLikelihood ,
0 commit comments