def TFE_run_listener(request):
    """Process TFE Run requests."""
    project_name = glom(request, 'data.0.project_name', default=False).replace(
      '/', '-')
    repo_url = glom(request, 'data.0.repo_url', default=False)
    branch = glom(request, 'data.0.module_version', default=False)
    workspace_id = glom(request, 'data.0.workspace_id', default=False)
    region = glom(request, 'data.0.region', default=False)
    # get the configuraiton version upload url
    upload_url = (
      tfe_run_handler.get_upload_url(region, workspace_id))
    log.info('configuration version response: {}'.format(upload_url))
    # download the source module
    git_handler.clone_repo(repo_url, project_name, branch)
    # zip the module
    # adding extra steps wenbhook side (clone then zip vice just download the
    # 'pre-zipped' repo) to avoid having to work with gitlab api tokens
    tar_path = git_handler.file_check(
      git_handler.compress_project(project_name))
    response = tfe_run_handler.upload_configuration_files(upload_url,
                                                          tar_path)
    git_handler.cleanup(project_name)
    if not response:
        response = '{"Status": "SUCCESS"}'
    return response
def create_sn_template(repo_url, project_name, repo_namespace, module_version,
                       cat_item_name, cat_item_description, sn_conf):
    """Create SN template."""
    project_path = git_handler.clone_repo(repo_url, project_name)
    vars_tf_path = git_handler.get_tf_vars_file(project_path)
    cat_sys_id = create_sn_cat_item(cat_item_name, cat_item_description,
                                    sn_conf)
    vars_tf_json_obj = hcl_to_json(vars_tf_path)
    create_cat_item_vars(vars_tf_json_obj, cat_sys_id, repo_namespace,
                         module_version, sn_conf)
    git_handler.cleanup(project_name)