def repos_collection():
    """
    The POST data should be in this format:

    {
      "gitRepoUrl": <git repo url>,
      "gitBranch": <git branch>,    - Optional, default is master
      "layout": <the layout json data>,
      "localBasePath": <the local base path for the code repo>    - Optional
    }

    :return:
    """
    try:
        if request.method == 'GET':
            return Response(repo_mgr.list_repos(), mimetype='application/json')
        if request.method == 'POST':
            if request.data:
                repo_para = json.loads(request.data)
                if 'gitRepoUrl' not in repo_para or \
                                'layout' not in repo_para:
                    return '{ "created":false, "message": "Parameters Error" }', 500
                result = repo_mgr.create_new_repo(repo_para.get('gitRepoUrl'),
                                                  repo_para.get('layout'),
                                                  git_branch=repo_para.get('gitBranch'),
                                                  local_base_path=repo_para.get('localBasePath'))
                return Response(json.dumps(result), mimetype='application/json')
    except Exception, e:
        logger.error("Error %s" % str(e), exc_info=True)
        return '{ "created":false, "message": "%s" }' % e, 500
def inventory_collection():
    """
    The POST data should be in this format:

    {
      "name": <inventory name>,
      "content": <inventory content>
    }

    :return:

    {
      "name": <inventory name>,
      "content": <inventory content>,
      "path": <inventory path on the server>,
      "message": "created"
    }
    """
    try:
        if request.method == 'GET':
            logger.info('hi')
            return Response('{ "msg":"hello"}', mimetype='application/json')
    except Exception, e:
        logger.error("Error %s" % str(e), exc_info=True)
        return Response('error', mimetype='application/json')
Example #3
0
def inventory_collection():
    """
    The POST data should be in this format:

    {
      "name": <inventory name>,
      "content": <inventory content>
    }

    :return:

    {
      "name": <inventory name>,
      "content": <inventory content>,
      "path": <inventory path on the server>,
      "message": "created"
    }
    """
    try:
        if request.method == 'GET':
            logger.info('hi')
            return Response('{ "msg":"hello"}', mimetype='application/json')
    except Exception, e:
        logger.error("Error %s" % str(e), exc_info=True)
        return Response('error', mimetype='application/json')
def _make_error_response(status_code, error_message):
    logger.error("Error Code:%s-%s" % (status_code, error_message), exc_info=True)
    returned_error_dict = {"error_message": error_message}
    return make_response(json.jsonify(returned_error_dict), status_code)
Example #5
0
def _make_error_response(status_code, error_message):
    logger.error("Error Code:%s-%s" % (status_code, error_message),
                 exc_info=True)
    returned_error_dict = {"error_message": error_message}
    return make_response(json.jsonify(returned_error_dict), status_code)