Ejemplo n.º 1
0
    def get(self, shortcode):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        req = dao.get_requirement_by_shortcode(shortcode)
        dao.close()

        resp = make_response(json_serialize(req, session_id=session_id),
                             httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 2
0
    def get(self, name):
        session_id = get_session_id(session, request)
        ordered = request.args.get('ordered', '1')

        dao = RequirementDAO(session_id)
        reqs = dao.get_requirements(constraint_id=name,
                                    is_asset=False,
                                    ordered=(ordered == '1'))
        dao.close()

        resp = make_response(json_serialize(reqs, session_id=session_id),
                             httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 3
0
    def get(self):
        session_id = get_session_id(session, request)
        ordered = request.args.get('ordered', 0)
        constraint_id = request.args.get('constraint_id', '')

        dao = RequirementDAO(session_id)
        reqs = dao.get_requirements(constraint_id=constraint_id,
                                    ordered=(ordered == '1'))
        dao.close()

        resp = make_response(json_serialize(reqs, session_id=session_id),
                             httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        resp.headers['Access-Control-Allow-Origin'] = "*"
        return resp
Ejemplo n.º 4
0
    def put(self):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        req = dao.from_json(request)
        dao.update_requirement(req, req_id=req.theId)
        dao.close()

        resp_dict = {'message': 'Requirement successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 5
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        dao.delete_requirement(name=name)
        dao.close()

        resp_dict = {'message': 'Requirement successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 6
0
    def post(self):
        session_id = get_session_id(session, request)
        asset_name = request.args.get('asset', None)
        environment_name = request.args.get('environment', None)

        dao = RequirementDAO(session_id)
        new_req = dao.from_json(request)
        req_id = dao.add_requirement(new_req,
                                     asset_name=asset_name,
                                     environment_name=environment_name)
        dao.close()

        resp_dict = {
            'message': 'Requirement successfully added',
            'requirement_id': req_id
        }
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp