How to use the girder.api.access.user 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 Kitware / cumulus / girder / task / server / task.py View on Github external
    @access.user
    def run(self, id, params):
        user = self.getCurrentUser()

        variables = json.load(cherrypy.request.body)

        task = self._model.load(id, user=user)
        task['status'] = 'running'
        task['output'] = {}
        task['log'] = []
        task['onTerminate'] = []
        task['onDelete'] = []
        task['startTime'] = int(round(time.time() * 1000))

        self._model.update_task(user, task)

        try:
github girder / girder / plugins / item_tasks / girder_item_tasks / rest.py View on Github external
    @access.user(scope=constants.TOKEN_SCOPE_EXECUTE_TASK)
    @filtermodel(model=Job)
    @autoDescribeRoute(
        Description('Execute a task described by an item.')
        .modelParam('id', 'The ID of the item representing the task specification.', model=Item,
                    level=AccessType.READ, requiredFlags=constants.ACCESS_FLAG_EXECUTE_TASK)
        .param('jobTitle', 'Title for this job execution.', required=False)
        .param('includeJobInfo', 'Whether to track the task using a job record.',
               required=False, dataType='boolean', default=True)
        .jsonParam('inputs', 'The input bindings for the task.', required=False,
                   requireObject=True)
        .jsonParam('outputs', 'The output bindings for the task.', required=False,
                   requireObject=True)
    )
    def executeTask(self, item, jobTitle, includeJobInfo, inputs, outputs):
        user = self.getCurrentUser()
        if jobTitle is None:
github girder / girder / girder / api / v1 / folder.py View on Github external
    @access.user(scope=TokenScope.DATA_WRITE)
    @filtermodel(model=FolderModel)
    @autoDescribeRoute(
        Description('Create a new folder.')
        .responseClass('Folder')
        .param('parentType', "Type of the folder's parent", required=False,
               enum=['folder', 'user', 'collection'], default='folder')
        .param('parentId', "The ID of the folder's parent.")
        .param('name', 'Name of the folder.', strip=True)
        .param('description', 'Description for the folder.', required=False,
               default='', strip=True)
        .param('reuseExisting', 'Return existing folder if it exists rather than '
               'creating a new one.', required=False,
               dataType='boolean', default=False)
        .param('public', 'Whether the folder should be publicly visible. By '
               'default, inherits the value from parent folder, or in the '
               'case of user or collection parentType, defaults to False.',
github girder / large_image / girder_annotation / girder_large_image_annotation / rest / annotation.py View on Github external
    @access.user
    @loadmodel(model='annotation', plugin='large_image', level=AccessType.READ)
    @filtermodel(model='annotation', plugin='large_image')
    def copyAnnotation(self, annotation, params):
        itemId = params['itemId']
        user = self.getCurrentUser()
        Item().load(annotation.get('itemId'),
                    user=user,
                    level=AccessType.READ)
        item = Item().load(itemId, user=user, level=AccessType.WRITE)
        return Annotation().createAnnotation(
            item, user, annotation['annotation'])
github Kitware / HPCCloud / server / hpccloud / hpccloud_plugin / projects.py View on Github external
    @access.user
    def delete(self, project, params):
        user = getCurrentUser()
        self._model.delete(user, project)
github Kitware / minerva / server / rest / postgres_geojson.py View on Github external
    @access.user
    @loadmodel(model='assetstore', map={'assetstoreId': 'assetstore'})
    @describeRoute(
        Description('Returns list of tables from a database assetstore')
        .param('assetstoreId', 'assetstore ID of the target database')
    )
    def getTables(self, assetstore, params):
        adapter = assetstore_utilities.getAssetstoreAdapter(assetstore)
        tables = adapter.getTableList()
        # tables is an array of databases, each of which has tables.  We
        # probably want to change this to not just use the first database.
        return [table['name'] for table in tables[0]['tables']]
github Kitware / cumulus / girder / cumulus / cumulus_plugin / volume.py View on Github external
    @access.user(scope=TokenScope.DATA_WRITE)
    @loadmodel(map={'clusterId': 'cluster'}, model='cluster', plugin='cumulus',
               level=AccessType.ADMIN)
    @loadmodel(model='volume', plugin='cumulus', level=AccessType.ADMIN)
    def attach(self, volume, cluster, params):
        body = getBodyJson()

        self.requireParams(['path'], body)
        path = body['path']

        profile_id = parse('profileId').find(volume)[0].value
        profile, secret_key = _get_profile(profile_id)

        girder_callback_info = {
            'girder_api_url': cumulus.config.girder.baseUrl,
            'girder_token': get_task_token()['_id']}
        log_write_url = '%s/volumes/%s/log' % (cumulus.config.girder.baseUrl,
github girder / covalic / covalic / rest / submission.py View on Github external
    @access.user
    @loadmodel(model='phase', plugin='covalic', level=AccessType.ADMIN)
    def getUnscoredSubmissions(self, params):
        # TODO implement
        pass
    getUnscoredSubmissions.description = (
github nasa-jpl-memex / image_space / imagespace_smqtk / server / smqtk_iqr.py View on Github external
    @access.user
    @describeRoute(
        Description('Create an IQR session, return the Girder Item representing that session')
    )
    def createSession(self, params):
        sessionsFolder = getCreateSessionsFolder()
        sessionId = requests.post(self.search_url + '/session').json()['sid']
        item = ModelImporter.model('item').createItem(name=sessionId,
                                                      creator=getCurrentUser(),
                                                      folder=sessionsFolder)
        ModelImporter.model('item').setMetadata(item, {
            'sid': sessionId
        })

        return item
        # create sessions folder in private directory if not existing
github Kitware / cumulus / girder / cumulus / cumulus_plugin / volume.py View on Github external
    @access.user(scope=TokenScope.DATA_READ)
    @loadmodel(model='volume', plugin='cumulus', level=AccessType.ADMIN)
    def get_status(self, volume, params):
        return {'status': volume['status']}