def index(self, trans, **kwd): """ GET /api/remote_files/ Displays remote files. :param target: target to load available datasets from, defaults to ftp possible values: ftp, userdir, importdir :type target: str :param format: requested format of data, defaults to flat possible values: flat, jstree, ajax :returns: list of available files :rtype: list """ target = kwd.get('target', None) format = kwd.get('format', None) if target == 'userdir': user_login = trans.user.email user_base_dir = trans.app.config.user_library_import_dir if user_base_dir is None: raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow upload from user directories.' ) full_import_dir = os.path.join(user_base_dir, user_login) if not os.path.exists(full_import_dir): raise exceptions.ObjectNotFound( 'You do not have any files in your user directory. Use FTP to upload there.' ) if full_import_dir is not None: if format == 'jstree': disable = kwd.get('disable', 'folders') try: userdir_jstree = self.__create_jstree( full_import_dir, disable) response = userdir_jstree.jsonData() except Exception, exception: log.debug(str(exception)) raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str(full_import_dir)) if not response: raise exceptions.ObjectNotFound( 'You do not have any files in your user directory. Use FTP to upload there.' ) elif format == 'ajax': raise exceptions.NotImplemented( 'Not implemented yet. Sorry.') else: try: response = self.__load_all_filenames(full_import_dir) except Exception, exception: log.error('Could not get user import files: %s', str(exception), exc_info=True) raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' )
def create(self, trans, payload, **kwd): """ POST /api/users Creates a new Galaxy user. """ if not trans.app.config.allow_user_creation and not trans.user_is_admin: raise exceptions.ConfigDoesNotAllowException( 'User creation is not allowed in this Galaxy instance') if trans.app.config.use_remote_user and trans.user_is_admin: user = trans.get_or_create_remote_user( remote_user_email=payload['remote_user_email']) elif trans.user_is_admin: username = payload['username'] email = payload['email'] password = payload['password'] message = "\n".join((validate_email(trans, email), validate_password(trans, password, password), validate_publicname(trans, username))).rstrip() if message: raise exceptions.RequestParameterInvalidException(message) else: user = self.user_manager.create(email=email, username=username, password=password) else: raise exceptions.NotImplemented() item = user.to_dict(view='element', value_mapper={ 'id': trans.security.encode_id, 'total_disk_usage': float }) return item
def update(self, trans, id, library_id, payload, **kwd): """ PUT /api/folders/{encoded_folder_id} """ raise exceptions.NotImplemented( 'Updating folder through this endpoint is not implemented yet.')
def index( self, trans, **kwd ): """ *GET /api/folders/ This would normally display a list of folders. However, that would be across multiple libraries, so it's not implemented. """ raise exceptions.NotImplemented( 'Listing all accessible library folders is not implemented.' )
def list_accessible(self, trans, user, **kwargs): """ Return a list of items accessible to the user, raising an error if ANY are inaccessible. :raises exceptions.ItemAccessibilityException: """ raise exceptions.NotImplemented("Abstract Interface Method")
def list_owned(self, user, **kwargs): """ Return a list of items owned by the user, raising an error if ANY are not. :raises exceptions.ItemAccessibilityException: """ raise exceptions.NotImplemented("Abstract interface Method")
def resolver_requirements(self, index): requirements = [] resolver = self._dependency_resolver(index) if not hasattr(resolver, "list_dependencies"): raise exceptions.NotImplemented() for requirement in resolver.list_dependencies(): requirements.append(requirement.to_dict()) return requirements
def clean(self, index=None, **kwds): if index: resolver = self._dependency_resolver(index) if not hasattr(resolver, "clean"): raise exceptions.NotImplemented() else: resolver.clean() return "OK" else: [resolver.clean(**kwds) for resolver in self._dependency_resolvers if hasattr(resolver, 'clean')] return "OK"
def _install_dependency(self, index, **payload): """ Resolver install dependency should return True when installation succeeds, False if not successful """ resolver = self._dependency_resolver(index) if not hasattr(resolver, "install_dependency"): raise exceptions.NotImplemented() name, version, type, extra_kwds = self._parse_dependency_info(payload) return resolver.install_dependency(name=name, version=version, type=type, **extra_kwds)
def index(self, trans, **kwd): """ GET /api/tools Displays a collection of tools with optional criteria. :param q: (optional)if present search on the given query will be performed :type q: str :param page: (optional)requested page of the search :type page: int :param page_size: (optional)requested page_size of the search :type page_size: int :param jsonp: (optional)flag whether to use jsonp format response, defaults to False :type jsonp: bool :param callback: (optional)name of the function to wrap callback in used only when jsonp is true, defaults to 'callback' :type callback: str :returns dict: object containing list of results and metadata Examples: GET http://localhost:9009/api/tools GET http://localhost:9009/api/tools?q=fastq """ q = kwd.get('q', '') if not q: raise exceptions.NotImplemented( 'Listing of all the tools is not implemented. Provide parameter "q" to search instead.' ) else: page = kwd.get('page', 1) page_size = kwd.get('page_size', 10) try: page = int(page) page_size = int(page_size) except ValueError: raise exceptions.RequestParameterInvalidException( 'The "page" and "page_size" have to be integers.') return_jsonp = util.asbool(kwd.get('jsonp', False)) callback = kwd.get('callback', 'callback') search_results = self._search(trans, q, page, page_size) if return_jsonp: response = str('%s(%s);' % (callback, json.dumps(search_results))) else: response = json.dumps(search_results) return response
def delete(self, trans, id, **kwd): """ DELETE /api/users/{id} delete the user with the given ``id`` :param id: the encoded id of the user to delete :type id: str :param purge: (optional) if True, purge the user :type purge: bool """ if not trans.app.config.allow_user_deletion: raise exceptions.ConfigDoesNotAllowException('The configuration of this Galaxy instance does not allow admins to delete users.') purge = util.string_as_bool(kwd.get('purge', False)) if purge: raise exceptions.NotImplemented('Purge option has not been implemented yet') user = self.get_user(trans, id) self.user_manager.delete(user) return self.user_serializer.serialize_to_view(user, view='detailed')
def copy(self, item, **kwargs): """ Clone or copy an item. """ raise exceptions.NotImplemented('Abstract method')
def create(self, trans, payload, **kwd): """ See the create method in tools.py in order to submit a job. """ raise exceptions.NotImplemented('Please POST to /api/tools instead.')
def undelete(self, trans, **kwd): raise exceptions.NotImplemented()
def undelete(self, trans: ProvidesHistoryContext, **kwd): raise exceptions.NotImplemented()
def is_owner(self, trans, item, user): """ Return True if user owns the item. """ # override in subclasses raise exceptions.NotImplemented("Abstract Interface Method")
def index(self, trans, **kwd): raise exceptions.NotImplemented("Listing uploads is not implemented.")
def by_user(self, user): raise exceptions.NotImplemented('Abstract Method')
def is_accessible(self, trans, item, user): """ Return True if the item accessible to user. """ # override in subclasses raise exceptions.NotImplemented("Abstract Interface Method")
def update(self, trans, id, library_id, payload, **kwd): """ PUT /api/folders/{encoded_folder_id}/contents """ raise exceptions.NotImplemented( 'Updating the library folder content is not implemented here.')
def _set_permissions(self, trans, dataset_assoc, roles_dict): raise exceptions.NotImplemented()
if base_dir is None: raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow usage of import directory.' ) if format == 'jstree': disable = kwd.get('disable', 'folders') try: importdir_jstree = self.__create_jstree(base_dir, disable) response = importdir_jstree.jsonData() except Exception, exception: log.debug(str(exception)) raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str(base_dir)) elif format == 'ajax': raise exceptions.NotImplemented('Not implemented yet. Sorry.') else: try: response = self.__load_all_filenames(base_dir) except Exception, exception: log.error('Could not get user import files: %s', str(exception), exc_info=True) raise exceptions.InternalServerError( 'Could not get the files from your import directory folder.' ) else: user_ftp_base_dir = trans.app.config.ftp_upload_dir if user_ftp_base_dir is None: raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow upload from FTP directories.'
def filter_accessible(self, trans, user, **kwargs): """ Return a list of items accessible to the user. """ raise exceptions.NotImplemented("Abstract Interface Method")
def show(self, trans, id, library_id, **kwd): """ GET /api/folders/{encoded_folder_id}/ """ raise exceptions.NotImplemented( 'Showing the library folder content is not implemented here.')
def copy(self, dataset, **kwargs): raise exceptions.NotImplemented('Datasets cannot be copied')