def get(self): session = app.session_maker() query = session.query(Sample) args = self.reqparse.parse_args() # build a dictionary and then unpack it into # the filter_by arguments using ** kwargs = {} limit = args.get('limit') offset = args.get('offset') for k, v in args.iteritems(): if v != None and k != 'limit' and k != 'offset' and ( (type(v) == str and len(v) > 0) or (type(v) == int and v > 0)): kwargs[k] = v if len(kwargs) > 0: print "Applying ", len(kwargs), " filters" query = query.filter_by(**kwargs) return { 'samples': marshal(query.limit(limit).offset(offset).all(), sample_uris), 'sample_count': query.count(), 'next_page': '/ngssm/api/v1.0/samples?limit=' + str(limit) + '&offset=' + str(offset + limit) }
def get(self, id): session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first() print "Sample id: ", id, " Sample: ", sample if sample == None: abort(404) return {'sample': marshal(sample, sample_fields)}
def get(self, id): session = app.session_maker() run = session.query(Run).filter_by(id=id).first(); print "Run id: ", id, " Run: ", run if run == None: abort(404) return { 'run': marshal(run, run_fields) }
def get(self, id): session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first(); print "Sample id: ", id, " Sample: ", sample if sample == None: abort(404) return { 'sample': marshal(sample, sample_fields) }
def delete(self, id): session = app.session_maker() run = session.query(Run).filter_by(id=id).first() if run == None: abort(404) session.delete(run) session.commit() return { 'result': True }
def delete(self, id): print "Received delete request for: ", id session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first() if sample == None: abort(404) session.delete(sample) session.commit() return {'result': True}
def delete(self, id): print "Received delete request for: ", id session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first() if sample == None: abort(404) session.delete(sample) session.commit() return { 'result': True }
def post(self): args = self.postreqparse.parse_args(); run = Run() for k, v in args.iteritems(): if v != None: setattr(run,k,v) session = app.session_maker() session.add(run) session.commit() return { 'run': marshal(run, run_fields) } , 201
def put(self, id): session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first() args = self.reqparse.parse_args() if sample == None: abort(404) for k, v in args.iteritems(): if v != None: setattr(sample, k, v) session.commit() return {'sample': marshal(sample, sample_fields)}
def put(self, id): session = app.session_maker() run = session.query(Run).filter_by(id=id).first() args = self.reqparse.parse_args(); if run == None: abort(404) for k, v in args.iteritems(): if v != None: setattr(run,k,v) session.commit() return { 'run': marshal(run, run_fields) }
def put(self, id): session = app.session_maker() sample = session.query(Sample).filter_by(id=id).first() args = self.reqparse.parse_args(); if sample == None: abort(404) for k, v in args.iteritems(): if v != None: setattr(sample,k,v) session.commit() return { 'sample': marshal(sample, sample_fields) }
def post(self): args = self.postreqparse.parse_args() if not 'run_id' in args: abort(400) sample = Sample() for k, v in args.iteritems(): if v != None: setattr(sample, k, v) session = app.session_maker() session.add(sample) session.commit() return {'sample': marshal(sample, sample_fields)}, 201
def post(self): args = self.postreqparse.parse_args(); if not 'run_id' in args: abort(400) sample = Sample() for k, v in args.iteritems(): if v != None: setattr(sample,k,v) session = app.session_maker() session.add(sample) session.commit() return { 'sample': marshal(sample, sample_fields) } , 201
def get(self): session = app.session_maker() query = session.query(Sample) args = self.reqparse.parse_args(); # build a dictionary and then unpack it into # the filter_by arguments using ** kwargs = {} for k, v in args.iteritems(): if v != None and len(v) > 0: kwargs[k]=v if len(kwargs) > 0: print "Applying ", len(kwargs), " filters" query = query.filter_by(**kwargs) return { 'samples': marshal(query.all(), sample_fields), 'samples_count': query.count() }
def get(self): session = app.session_maker() query = session.query(Run) args = self.reqparse.parse_args(); # build a dictionary and then unpack it into # the filter_by arguments using ** kwargs = {} limit = args.get('limit') offset = args.get('offset') for k, v in args.iteritems(): if v != None and type(v) is str and len(v) > 0: kwargs[k]=v if len(kwargs) > 0: print "Applying ", len(kwargs), " filters" query = query.filter_by(**kwargs) return { 'runs': marshal(query.limit(limit).offset(offset).all(), run_uris), 'run_count': query.count(), 'next_page': '/ngssm/api/v1.0/runs?limit=' + str(limit) + '&offset=' + str(offset + limit) }