Ejemplo n.º 1
0
def create_or_update(project_id):
    try:  # get project fields
        args = request.get_json(force=True)
        name = args['name']
        version = args['version']
        containers = args['containers']

    except Exception as e:
        logger.error("failed to setup variables passed in because %s" % e, exc_info=True)
        raise errors.InvalidUsage()

    try:
        if request.method.upper() == "POST":
            return jsonified(data=models.project_create(name=name, containers=containers, version=version))
        else:
            return jsonified(data=models.project_update(name=name, containers=containers, version=version,
                                                        project_id=project_id))

    except exc.SystemInvalid as e:
        raise errors.Unhandled(e)

    except exc.UserInvalidUsage as e:
        raise errors.InvalidUsage(e)

    except Exception as e:
        logger.error("failed to create new project because %s" % e, exc_info=True)
        # TODO rollback on error, deleting keys possibly created
        raise errors.Unhandled()
Ejemplo n.º 2
0
def create_or_update(project_id):
    try:  # get project fields
        args = request.get_json(force=True)
        name = args['name']
        version = args['version']
        containers = args['containers']

    except Exception as e:
        logger.error("failed to setup variables passed in because %s" % e,
                     exc_info=True)
        raise errors.InvalidUsage()

    try:
        if request.method.upper() == "POST":
            return jsonified(data=models.project_create(
                name=name, containers=containers, version=version))
        else:
            return jsonified(data=models.project_update(name=name,
                                                        containers=containers,
                                                        version=version,
                                                        project_id=project_id))

    except exc.SystemInvalid as e:
        raise errors.Unhandled(e)

    except exc.UserInvalidUsage as e:
        raise errors.InvalidUsage(e)

    except Exception as e:
        logger.error("failed to create new project because %s" % e,
                     exc_info=True)
        # TODO rollback on error, deleting keys possibly created
        raise errors.Unhandled()
Ejemplo n.º 3
0
def listing(project_id):
    try:
        return jsonified(data=models.project_listing(project_id=project_id))

    except exc.UserNotFound as e:
        raise errors.NotFound(e)

    except Exception as e:
        logger.error("unhandled error {e}".format(e=e), exc_info=True)
        raise errors.Unhandled()
Ejemplo n.º 4
0
def listing(project_id):
    try:
        return jsonified(data=models.project_listing(project_id=project_id))

    except exc.UserNotFound as e:
        raise errors.NotFound(e)

    except Exception as e:
        logger.error("unhandled error {e}".format(e=e), exc_info=True)
        raise errors.Unhandled()
Ejemplo n.º 5
0
def remove(project_id):
    try:
        return jsonified(data=models.project_delete(project_id=project_id))

    except exc.SystemInvalid as e:
        raise errors.Unhandled(e)

    except exc.UserNotFound as e:
        raise errors.InvalidUsage(e)

    except Exception as e:
        logger.error("failed to delete because %s" % e, exc_info=True)
        raise errors.InvalidUsage()
Ejemplo n.º 6
0
def remove(project_id):
    try:
        return jsonified(data=models.project_delete(project_id=project_id))

    except exc.SystemInvalid as e:
        raise errors.Unhandled(e)

    except exc.UserNotFound as e:
        raise errors.InvalidUsage(e)

    except Exception as e:
        logger.error("failed to delete because %s" % e, exc_info=True)
        raise errors.InvalidUsage()