24
24
# [START dlp_create_trigger]
25
25
def create_trigger (project , bucket , scan_period_days , info_types ,
26
26
trigger_id = None , display_name = None , description = None ,
27
- min_likelihood = None , max_findings = None ):
27
+ min_likelihood = None , max_findings = None ,
28
+ auto_populate_timespan = False ):
28
29
"""Creates a scheduled Data Loss Prevention API inspect_content trigger.
29
30
Args:
30
31
project: The Google Cloud project id to use as a parent resource.
@@ -42,6 +43,8 @@ def create_trigger(project, bucket, scan_period_days, info_types,
42
43
that constitutes a match. One of: 'LIKELIHOOD_UNSPECIFIED',
43
44
'VERY_UNLIKELY', 'UNLIKELY', 'POSSIBLE', 'LIKELY', 'VERY_LIKELY'.
44
45
max_findings: The maximum number of findings to report; 0 = no maximum.
46
+ auto_populate_timespan: Automatically populates time span config start
47
+ and end times in order to scan new content only.
45
48
Returns:
46
49
None; the response from the API is printed to the terminal.
47
50
"""
@@ -69,7 +72,13 @@ def create_trigger(project, bucket, scan_period_days, info_types,
69
72
storage_config = {
70
73
'cloud_storage_options' : {
71
74
'file_set' : {'url' : url }
72
- }
75
+ },
76
+ # Time-based configuration for each storage object.
77
+ 'timespan_config' : {
78
+ # Auto-populate start and end times in order to scan new objects
79
+ # only.
80
+ 'enable_auto_population_of_timespan_config' : auto_populate_timespan
81
+ },
73
82
}
74
83
75
84
# Construct the job definition.
@@ -222,6 +231,9 @@ def delete_trigger(project, trigger_id):
222
231
parser_create .add_argument (
223
232
'--max_findings' , type = int ,
224
233
help = 'The maximum number of findings to report; 0 = no maximum.' )
234
+ parser_create .add_argument (
235
+ '--auto_populate_timespan' , type = bool ,
236
+ help = 'Limit scan to new content only.' )
225
237
226
238
parser_list = subparsers .add_parser ('list' , help = 'List all triggers.' )
227
239
parser_list .add_argument (
@@ -246,6 +258,7 @@ def delete_trigger(project, trigger_id):
246
258
trigger_id = args .trigger_id , display_name = args .display_name ,
247
259
description = args .description , min_likelihood = args .min_likelihood ,
248
260
max_findings = args .max_findings ,
261
+ auto_populate_timespan = args .auto_populate_timespan ,
249
262
)
250
263
elif args .action == 'list' :
251
264
list_triggers (args .project )
0 commit comments