in 5-app-infra/3-artifact-publish/docker/cdmc/tag_engine_api/main.py [0:0]
def process_sensitive_column_config():
template_id = request.form['template_id']
template_project = request.form['template_project']
template_region = request.form['template_region']
service_account = request.form['service_account']
dlp_dataset = request.form['dlp_dataset'].rstrip()
infotype_selection_table = request.form['infotype_selection_table'].rstrip()
infotype_classification_table = request.form['infotype_classification_table'].rstrip()
included_tables_uris = request.form['included_tables_uris'].rstrip()
excluded_tables_uris = request.form['excluded_tables_uris'].rstrip()
# policy tag inputs
policy_tags = request.form['policy_tags']
if policy_tags == "true":
create_policy_tags = True
taxonomy_id = request.form['taxonomy_id'].rstrip()
else:
create_policy_tags = False
taxonomy_id = None
refresh_mode = request.form['refresh_mode']
refresh_frequency = request.form['refresh_frequency']
refresh_unit = request.form['refresh_unit']
overwrite = True # set to true as we are creating a new sensitive config
action = request.form['action']
credentials, success = get_target_credentials(service_account)
if success == False:
print('Error acquiring credentials from', service_account)
dcc = controller.DataCatalogController(credentials, None, None, template_id, template_project, template_region)
template = dcc.get_template()
if action == "Cancel Changes":
return render_template(
'tag_template.html',
template_id=template_id,
template_project=template_project,
template_region=template_region,
service_account=service_account,
fields=template)
fields = []
selected_fields = request.form.getlist("selected")
#print("selected_fields: " + str(selected_fields))
for selected_field in selected_fields:
selected_field_type = request.form.get(selected_field + "_datatype")
#print(selected_field + ", " + selected_field_type)
for template_field in template:
if template_field['field_id'] != selected_field:
continue
is_required = template_field['is_required']
field = {'field_id': selected_field, 'field_type': selected_field_type,\
'is_required': is_required}
fields.append(field)
break
#print('fields: ' + str(fields))
if excluded_tables_uris == 'None':
excluded_tables_uris = ''
tag_history_option, _ = store.read_tag_history_settings()
if tag_history_option == True:
tag_history_display = "ON"
else:
tag_history_display = "OFF"
template_uuid = store.write_tag_template(template_id, template_project, template_region)
config_uuid = store.write_sensitive_column_config(service_account, fields, dlp_dataset, infotype_selection_table, \
infotype_classification_table, included_tables_uris, excluded_tables_uris, \
create_policy_tags, taxonomy_id, template_uuid, template_id, template_project, \
template_region, refresh_mode, refresh_frequency, refresh_unit, \
tag_history_option, overwrite)
# [END process_sensitive_column_config]
# [START render_template]
return render_template(
'created_sensitive_column_config.html',
config_uuid=config_uuid,
config_type='SENSITIVE_TAG_COLUMN',
template_id=template_id,
template_project=template_project,
template_region=template_region,
service_account=service_account,
fields=fields,
dlp_dataset=dlp_dataset,
infotype_selection_table=infotype_selection_table,
infotype_classification_table=infotype_classification_table,
included_tables_uris=included_tables_uris,
excluded_tables_uris=excluded_tables_uris,
policy_tags=policy_tags,
taxonomy_id=taxonomy_id,
refresh_mode=refresh_mode,
refresh_frequency=refresh_frequency,
refresh_unit=refresh_unit,
tag_history=tag_history_display)