How to use the girder.api.describe.Description function in girder

To help you get started, we’ve selected a few girder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github girder / girder_worker / tests / integration / integration_test_endpoints / integration_test_endpoints / raw.py View on Github external
        Description('Test girder client with no token can\'t access protected resources'))
    def test_celery_girder_client_bad_token_fails(self, params):
        result = request_private_path.delay('admin', girder_client_token='')

        return result.job
github Kitware / minerva / server / rest / analysis.py View on Github external
}

        job = self.model('job', 'jobs').createLocalJob(
            title='MMWR import: %s' % datasetName,
            user=currentUser,
            type='bsve.mmwr',
            public=False,
            kwargs=kwargs,
            module='girder.plugins.minerva.jobs.soda_import_worker',
            async=True)
        addJobOutput(job, dataset)
        self.model('job', 'jobs').scheduleJob(job)
        return job

    bsveMMWRAnalysis.description = (
        Description('Create a new accumulated MMWR dataset from the BSVE.')
        .param('datasetName', 'Name of the dataset created by this analysis.')
        .param(
            'count', 'The number of items to get from the server',
            required=False
        )
github Kitware / minerva / server / rest / session.py View on Github external
    @access.public
    @loadmodel(map={'userId': 'user'}, model='user', level=AccessType.READ)
    def listSessions(self, user, params):
        folder = findSessionFolder(self.getCurrentUser(), user)
        if folder is None:
            return []
        else:
            limit, offset, sort = \
                self.getPagingParameters(params,
                                         defaultSortDir=pymongo.DESCENDING)
            items = [self.model('item').filter(item, self.getCurrentUser()) for
                     item in self.model('folder').childItems(folder,
                     limit=limit, offset=offset, sort=sort)]
            return items
    listSessions.description = (
        Description('List minerva sessions owned by a user.')
        .param('userId', 'User is the owner of minerva sessions.',
               required=True)
        .param('limit', "Result set size limit (default=50).", required=False,
               dataType='int')
        .param('offset', "Offset into result set (default=0).", required=False,
               dataType='int')
        .param('sort', 'Field to sort the result list by ('
               'default=name)', required=False)
        .param('sortdir', "1 for ascending, -1 for descending (default=-1)",
               required=False, dataType='int'))

    @access.public
    @loadmodel(map={'userId': 'user'}, model='user', level=AccessType.READ)
    def getSessionFolder(self, user, params):
        folder = findSessionFolder(self.getCurrentUser(), user, create=True)
        return {'folder': folder}
github nasa-jpl-memex / GeoParser / plugin / geoparser_plugin / server / __init__.py View on Github external
Find location name from extracted text using Geograpy.
        '''
        file_name = params['file_name']
        text_content = QueryText(file_name)
        if text_content:
            e = extraction.Extractor(text=text_content)
            e.find_entities()
            status = IndexLocationName(file_name, e.places)
            if status[0]:
                return {'job':'find_location', 'status': 'successful', 'comment':'Location/s found and indexed to Solr.'}
            else:
                return {'job':'find_location', 'status': 'unsuccessful', 'comment':status[1]}
        else:
            return {'job':'find_location', 'status': 'unsuccessful', 'comment':'Cannot extract text.'}
    findLocation.description = (
        Description('Find location name')
    )


    @access.public
    def findLatlon(self, params):
        '''
        Find latitude and longitude from location name using GeoPy.
        '''
        file_name = params['file_name']
        location_names = QueryLocationName(file_name)
        if location_names:
            points = []
            for location in location_names:
                try:
                    geolocation = geolocator.geocode(location)
                    points.append(
github DigitalSlideArchive / digital_slide_archive / server / rest / tcga.py View on Github external
    @access.public(scope=TokenScope.DATA_READ)
    @loadmodel(model='case', plugin='digital_slide_archive',
               level=AccessType.READ)
    @describeRoute(
        Description('Get a case document from an id')
        .param('id', 'The id of the case', paramType='path')
    )
    def getCase(self, case, params):
        return case
github Kitware / cumulus / girder / task / server / task.py View on Github external
spec = json.loads(spec)

            variables['task'] = self._clean(task)

            # Create token for user runnig this task
            token = self.model('token').createToken(user=user, days=7)
            variables['girderToken'] = token['_id']

            runner.run(token['_id'], self._clean(task), spec, variables)
        except requests.HTTPError as err:
            task['status'] = 'failure'
            self._model.update_task(user, task)
            raise RestException(err.response.content, err.response.status_code)

    run.description = (
        Description('Start the task running')
        .param(
            'id',
            'The id of task',
            required=True, paramType='path')
        .param(
            'variables',
            'The variable to render the task spec with',
            required=False, paramType='body'))

    @access.user
    def update(self, id, params):
        user = self.getCurrentUser()

        body = cherrypy.request.body.read()

        if not body:
github girder / girder / girder / api / v1 / user.py View on Github external
        Description('Log in to the system.')
        .notes('Pass your username and password using HTTP Basic Auth. Sends'
               ' a cookie that should be passed back in future requests.')
        .param('Girder-OTP', 'A one-time password for this user', paramType='header',
               required=False)
        .errorResponse('Missing Authorization header.', 401)
        .errorResponse('Invalid login or password.', 403)
    )
    def login(self):
        if not Setting().get(SettingKey.ENABLE_PASSWORD_LOGIN):
            raise RestException('Password login is disabled on this instance.')

        user, token = self.getCurrentUser(returnToken=True)

        # Only create and send new cookie if user isn't already sending a valid one.
        if not user:
            authHeader = cherrypy.request.headers.get('Authorization')
github Kitware / flow / server / __init__.py View on Github external
'status': 'FAILURE',
                'message': sys.exc_info(),
                'trace': sys.exc_info()[2]
            }
    flowRunStatus.description = (
        Description('Show the status of a flow task')
        .param('jobId', 'The job ID for this task.', paramType='path')
        .param('itemId', 'Not used.', paramType='path'))

    @access.public
    def flowRunResult(itemId, jobId, params):
        celeryTaskId = getTaskId(jobId)
        job = AsyncResult(celeryTaskId, backend=getCeleryApp().backend)
        return {'result': job.result}
    flowRunResult.description = (
        Description('Show the final output of a flow task.')
        .param('jobId', 'The job ID for this task.', paramType='path')
        .param('itemId', 'Not used.', paramType='path'))

    @access.public
    @rest.boundHandler(info['apiRoot'].item)
    @rest.loadmodel(map={'itemId': 'item'}, model='item',
                    level=AccessType.READ)
    def flowRun(self, item, params):
        # Make sure that we have permission to perform this analysis.
        # import pudb
        # pu.db
        user = self.getCurrentUser()

        settings = ModelImporter.model('setting')
        requireAuth = settings.get(FlowPluginSettings.REQUIRE_AUTH, True)
github girder / girder / girder / api / v1 / user.py View on Github external
        Description('Log out of the system.')
        .responseClass('Token')
        .notes('Attempts to delete your authentication cookie.')
    )
    def logout(self):
        token = self.getCurrentToken()
        if token:
            Token().remove(token)
        self.deleteAuthTokenCookie()
        return {'message': 'Logged out.'}
github Kitware / minerva / server / rest / wfs_dataset.py View on Github external
def createWfsDataset(self, wfsSource, params):
        baseURL = wfsSource['meta']['minerva']['wfs_params']['base_url']
        typeName = params['typeName']
        self.requireParams(('name'), params)
        name = params['name']
        minerva_metadata = {
            'dataset_type': 'wfs',
            #'legend': legend,
            'source_id': wfsSource['_id'],
            'type_name': typeName,
            'base_url': baseURL
        }
        dataset = self.constructDataset(name, minerva_metadata)
        return dataset
    createWfsDataset.description = (
        Description('Create a WFS Dataset from a WFS Source.')
        .responseClass('Item')
        .param('name', 'The name of the wfs dataset', required=True)
        .param('wfsSourceId', 'Item ID of the WFS Source', required=True)
        .param('typeName', 'The type name of the WFS layer', required=True)
        .errorResponse('ID was invalid.')
        .errorResponse('Read permission denied on the Item.', 403))

    @access.user
    def getBsveAuthHeader(self, params):
        (user, apikey, secret) = (environ.get('BSVE_USERNAME'),
                                  environ.get('BSVE_APIKEY'),
                                  environ.get('BSVE_SECRETKEY'))
        bu = bsve_utility.BsveUtility(user=user, apikey=apikey, secret=secret)
        return bu._auth_header()
    getBsveAuthHeader.description = (
        Description('Create a valid current BSVE Auth Header.'))