commit/galaxy-central: davebgx: Enhance the tool shed repository API controller to allow filtering by owner's username or repository name.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6b672fb12099/ Changeset: 6b672fb12099 User: davebgx Date: 2014-06-25 21:07:43 Summary: Enhance the tool shed repository API controller to allow filtering by owner's username or repository name. Affected #: 1 file diff -r 8a161a3990b5e19dd2b324323ba934f8a5f37c8b -r 6b672fb120994f308ce7914993418e67770aae14 lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -7,6 +7,7 @@ from galaxy import eggs from galaxy import util from galaxy import web +from galaxy.model.orm import and_ from galaxy.web.base.controller import BaseAPIController from galaxy.web.base.controller import HTTPBadRequest from galaxy.web.framework.helpers import time_ago @@ -297,16 +298,28 @@ return return_dict @web.expose_api_anonymous - def index( self, trans, deleted=False, **kwd ): + def index( self, trans, deleted=False, owner=None, name=None, **kwd ): """ GET /api/repositories + + :param deleted: True/False, displays repositories that are or are not set to deleted. + :param owner: the owner's public username. + :param name: the repository name. + Displays a collection (list) of repositories. """ # Example URL: http://localhost:9009/api/repositories repository_dicts = [] deleted = util.asbool( deleted ) + clause_list = [ and_( trans.app.model.Repository.table.c.deprecated == False, + trans.app.model.Repository.table.c.deleted == deleted ) ] + if owner is not None: + clause_list.append( and_( trans.app.model.User.table.c.username == owner, + trans.app.model.Repository.table.c.user_id == trans.app.model.User.table.c.id ) ) + if name is not None: + clause_list.append( trans.app.model.Repository.table.c.name == name ) for repository in trans.sa_session.query( trans.app.model.Repository ) \ - .filter( trans.app.model.Repository.table.c.deleted == deleted ) \ + .filter( *clause_list ) \ .order_by( trans.app.model.Repository.table.c.name ): repository_dict = repository.to_dict( view='collection', value_mapper=self.__get_value_mapper( trans ) ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org