in 5-app-infra/3-artifact-publish/docker/cdmc/tag_engine_api/main.py [0:0]
def process_import_config():
template_id = request.form['template_id']
template_project = request.form['template_project']
template_region = request.form['template_region']
data_asset_type = request.form['data_asset_type']
data_asset_region = request.form['data_asset_region']
metadata_import_location = request.form['metadata_import_location']
service_account = request.form['service_account']
action = request.form['action']
if 'config_uuid' in request.form:
config_uuid = request.form['config_uuid']
else:
config_uuid = None
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)
if action == "View Config List":
configs = store.read_configs(service_account, 'ALL', template_id, template_project, template_region)
print('configs: ', configs)
return render_template(
'view_configs.html',
template_id=template_id,
template_project=template_project,
template_region=template_region,
service_account=service_account,
configs=configs)
# action is Save Changes (either to a new config or existing one)
tag_history_option, _ = store.read_tag_history_settings()
if tag_history_option == True:
tag_history_display = "ON"
else:
tag_history_display = "OFF"
# update existing config
if config_uuid != None:
store.update_tag_import_config(config_uuid, data_asset_type, data_asset_region, metadata_import_location)
config = store.read_config(service_account, config_uuid, 'TAG_IMPORT')
return render_template(
'update_import_config.html',
template_id=template_id,
template_project=template_project,
template_region=template_region,
data_asset_type=data_asset_type,
data_asset_region=data_asset_region,
service_account=service_account,
config=config,
settings=1)
# write new config
else:
template_uuid = store.write_tag_template(template_id, template_project, template_region)
config_uuid = store.write_tag_import_config(service_account, template_uuid, template_id, template_project, template_region, \
data_asset_type, data_asset_region, metadata_import_location, tag_history_option)
return render_template(
'created_import_config.html',
config_uuid=config_uuid,
config_type='TAG_IMPORT',
template_id=template_id,
template_project=template_project,
template_region=template_region,
data_asset_type=data_asset_type,
data_asset_region=data_asset_region,
service_account=service_account,
metadata_import_location=metadata_import_location,
tag_history=tag_history_display)