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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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