Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DLP: Add auto_populate_timespan option for create job trigger. #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions 17 dlp/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
# [START dlp_create_trigger]
def create_trigger(project, bucket, scan_period_days, info_types,
trigger_id=None, display_name=None, description=None,
min_likelihood=None, max_findings=None):
min_likelihood=None, max_findings=None,
auto_populate_timespan=False):
"""Creates a scheduled Data Loss Prevention API inspect_content trigger.
Args:
project: The Google Cloud project id to use as a parent resource.
Expand All @@ -42,6 +43,8 @@ def create_trigger(project, bucket, scan_period_days, info_types,
that constitutes a match. One of: 'LIKELIHOOD_UNSPECIFIED',
'VERY_UNLIKELY', 'UNLIKELY', 'POSSIBLE', 'LIKELY', 'VERY_LIKELY'.
max_findings: The maximum number of findings to report; 0 = no maximum.
auto_populate_timespan: Automatically populates time span config start
and end times in order to scan new content only.
Returns:
None; the response from the API is printed to the terminal.
"""
Expand Down Expand Up @@ -69,7 +72,13 @@ def create_trigger(project, bucket, scan_period_days, info_types,
storage_config = {
'cloud_storage_options': {
'file_set': {'url': url}
}
},
# Time-based configuration for each storage object.
'timespan_config': {
# Auto-populate start and end times in order to scan new objects
# only.
'enable_auto_population_of_timespan_config': auto_populate_timespan
},
}

# Construct the job definition.
Expand Down Expand Up @@ -222,6 +231,9 @@ def delete_trigger(project, trigger_id):
parser_create.add_argument(
'--max_findings', type=int,
help='The maximum number of findings to report; 0 = no maximum.')
parser_create.add_argument(
'--auto_populate_timespan', type=bool,
help='Limit scan to new content only.')

parser_list = subparsers.add_parser('list', help='List all triggers.')
parser_list.add_argument(
Expand All @@ -246,6 +258,7 @@ def delete_trigger(project, trigger_id):
trigger_id=args.trigger_id, display_name=args.display_name,
description=args.description, min_likelihood=args.min_likelihood,
max_findings=args.max_findings,
auto_populate_timespan=args.auto_populate_timespan,
)
elif args.action == 'list':
list_triggers(args.project)
Expand Down
1 change: 1 addition & 0 deletions 1 dlp/triggers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_create_list_and_delete_trigger(bucket, capsys):
GCLOUD_PROJECT, bucket.name, 7,
['FIRST_NAME', 'EMAIL_ADDRESS', 'PHONE_NUMBER'],
trigger_id=TEST_TRIGGER_ID,
auto_populate_timespan=True,
)

out, _ = capsys.readouterr()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.