def process_created_config_action()

in 5-app-infra/3-artifact-publish/docker/cdmc/tag_engine_api/main.py [0:0]


def process_created_config_action():
    
    if 'credentials' not in session:
        return redirect('/')
        
    config_uuid = request.form['config_uuid']
    config_type = request.form['config_type']
    
    if 'template_id' in request.form:
        template_id = request.form['template_id']
    else:
        template_id = 'N/A' # export config handler
    
    if 'template_project' in request.form:
        template_project = request.form['template_project']
    else:
        template_project = 'N/A' # export config handler
        
    if 'template_region' in request.form:
        template_region = request.form['template_region']
    else:
        template_region = 'N/A' # export config handler
        
    if template_id == 'N/A' and template_project == 'N/A' and template_region == 'N/A':
        target_project = request.form['target_project']
        target_dataset = request.form['target_dataset']
    else:
        target_project = 'N/A'
        target_dataset = 'N/A'
    
    service_account = request.form['service_account']
    
    action = request.form['action']
    
    if action == "Trigger Job":
        job_uuid = jm.create_job(tag_creator_account=service_account, tag_invoker_account=session['user_email'], config_uuid=config_uuid, config_type=config_type)
        job = jm.get_job_status(job_uuid)
        
        entries = get_log_entries(service_account)
        
        return render_template(
            'job_status.html',
            job_uuid=job_uuid,
            entries=entries,
            job_status=job['job_status'],
            config_uuid=config_uuid,
            config_type=config_type,
            template_id=template_id,
            template_project=template_project,
            template_region=template_region,
            service_account=service_account,
            target_project=target_project,
            target_dataset=target_dataset)
   
    if action == "View Existing Configs":
        configs = store.read_configs(service_account, 'ALL', template_id, template_project, template_region)

        return render_template(
            'view_configs.html',
            template_id=template_id,
            template_project=template_project,
            template_region=template_region,
            service_account=service_account,
            configs=configs)
    
    if action == "Return Home":
        return render_template(
            'home.html',
            template_id=template_id,
            template_project=template_project,
            template_region=template_region,
            service_account=service_account)