Example #1
0
    def get(self, environment):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_asset_names(environment=environment)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #2
0
    def get(self, environment):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_asset_names(environment=environment)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #3
0
    def get(self):
        session_id = request.args.get('session_id', None)

        dao = AssetDAO(session_id)
        assets_names = dao.get_asset_names()
        dao.close()

        resp = make_response(json_serialize(assets_names, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #4
0
    def get(self, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_asset_values(environment_name=environment_name)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #5
0
    def get(self, name, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_value = dao.get_asset_value_by_name(name=name, environment_name=environment_name)
        dao.close()

        resp = make_response(json_serialize(asset_value, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #6
0
    def get(self, asset_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_props = dao.get_asset_props(name=asset_name)
        dao.close()

        resp = make_response(json_serialize(asset_props, session_id=session_id))
        resp.contenttype = 'application/json'
        return resp
Example #7
0
    def get(self, name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        found_asset = dao.get_asset_by_name(name)
        dao.close()

        resp = make_response(json_serialize(found_asset, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #8
0
    def delete(self, name):
        session_id = request.args.get('session_id', None)
        dao = AssetDAO(session_id)

        dao.delete_asset(name=name)
        dao.close()

        resp_dict = {'message': 'Asset successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #9
0
    def get(self):
        constraint_id = request.args.get('constraint_id', -1)
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_assets(constraint_id=constraint_id)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #10
0
    def get(self, asset_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_props = dao.get_asset_props(name=asset_name)
        dao.close()

        resp = make_response(json_serialize(asset_props,
                                            session_id=session_id))
        resp.contenttype = 'application/json'
        return resp
Example #11
0
    def get(self):
        session_id = request.args.get('session_id', None)

        dao = AssetDAO(session_id)
        assets_names = dao.get_asset_names()
        dao.close()

        resp = make_response(
            json_serialize(assets_names, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #12
0
    def get(self, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_asset_values(environment_name=environment_name)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id),
                             httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #13
0
    def get(self):
        constraint_id = request.args.get('constraint_id', -1)
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_assets(constraint_id=constraint_id)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #14
0
    def delete(self, name):
        session_id = request.args.get('session_id', None)
        dao = AssetDAO(session_id)

        dao.delete_asset(name=name)
        dao.close()

        resp_dict = {'message': 'Asset successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #15
0
    def get(self, name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        found_asset = dao.get_asset_by_name(name)
        dao.close()

        resp = make_response(json_serialize(found_asset,
                                            session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #16
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.from_json(request)
        dao.update_asset(asset, name=name)
        dao.close()

        resp_dict = {'message': 'Update successful'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #17
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.from_json(request)
        new_id = dao.add_asset(asset)
        dao.close()

        resp_dict = {'asset_id': new_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #18
0
    def get(self, id):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.get_asset_by_id(id)
        dao.close()
        if asset is None:
            raise ObjectNotFoundHTTPError('The asset')

        resp = make_response(json_serialize(asset, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #19
0
    def get(self, name, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_value = dao.get_asset_value_by_name(
            name=name, environment_name=environment_name)
        dao.close()

        resp = make_response(
            json_serialize(asset_value, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #20
0
    def get(self, id):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.get_asset_by_id(id)
        dao.close()
        if asset is None:
            raise ObjectNotFoundHTTPError('The asset')

        resp = make_response(json_serialize(asset, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Example #21
0
    def delete(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AssetDAO(session_id)
        dao.delete_asset_type(name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Asset type successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #22
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.from_json(request)
        new_id = dao.add_asset(asset)
        dao.close()

        resp_dict = {'asset_id': new_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #23
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.from_json(request)
        dao.update_asset(asset, name=name)
        dao.close()

        resp_dict = {'message': 'Update successful'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #24
0
    def delete(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AssetDAO(session_id)
        dao.delete_asset_type(name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Asset type successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #25
0
    def put(self, name, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_value = dao.type_from_json(request)
        dao.update_asset_value(asset_value, name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Asset type successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #26
0
    def put(self, asset_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_prop = dao.from_json(request, to_props=True)
        dao.update_asset_properties(asset_prop, name=asset_name)
        dao.close()

        resp_dict = {'message': 'The asset properties were successfully updated.'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #27
0
    def post(self):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AssetDAO(session_id)
        new_value_type = dao.type_from_json(request)
        asset_type_id = dao.add_asset_type(new_value_type, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Asset type successfully added', 'asset_type_id': asset_type_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #28
0
    def put(self, asset_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_prop = dao.from_json(request, to_props=True)
        dao.update_asset_properties(asset_prop, name=asset_name)
        dao.close()

        resp_dict = {
            'message': 'The asset properties were successfully updated.'
        }
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #29
0
    def put(self, name, environment_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_value = dao.type_from_json(request)
        dao.update_asset_value(asset_value,
                               name=name,
                               environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Asset type successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Example #30
0
    def post(self):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AssetDAO(session_id)
        new_value_type = dao.type_from_json(request)
        asset_type_id = dao.add_asset_type(new_value_type,
                                           environment_name=environment_name)
        dao.close()

        resp_dict = {
            'message': 'Asset type successfully added',
            'asset_type_id': asset_type_id
        }
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Example #31
0
    def get(self, environment):
        session_id = get_session_id(session, request)
        with_concerns = request.args.get('with_concerns', True)
        if with_concerns == '0' or with_concerns == 0:
            with_concerns = False
        model_generator = get_model_generator()

        dao = AssetDAO(session_id)
        dot_code = dao.get_asset_model(environment, with_concerns=with_concerns)
        dao.close()

        if not isinstance(dot_code, str):
            raise ObjectNotFoundHTTPError('The model')

        resp = make_response(model_generator.generate(dot_code), httplib.OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'

        return resp
Example #32
0
    def get(self, environment):
        session_id = get_session_id(session, request)
        with_concerns = request.args.get('with_concerns', True)
        if with_concerns == '0' or with_concerns == 0:
            with_concerns = False
        model_generator = get_model_generator()

        dao = AssetDAO(session_id)
        dot_code = dao.get_asset_model(environment,
                                       with_concerns=with_concerns)
        dao.close()

        if not isinstance(dot_code, str):
            raise ObjectNotFoundHTTPError('The model')

        resp = make_response(model_generator.generate(dot_code), httplib.OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'

        return resp