How to use the girder.api.describe.autoDescribeRoute 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 / girder / api / v1 / assetstore.py View on Github external
    @autoDescribeRoute(
        Description('Import existing data into an assetstore.')
        .notes('This does not move or copy the existing data, it just creates '
               'references to it in the Girder data hierarchy. Deleting '
               'those references will not delete the underlying data. This '
               'operation is currently only supported for S3 assetstores.')
        .modelParam('id', model='assetstore')
        .param('importPath', 'Root path within the underlying storage system '
               'to import.', required=False)
        .param('destinationId', 'ID of a folder, collection, or user in Girder '
               'under which the data will be imported.')
        .param('destinationType', 'Type of the destination resource.',
               enum=('folder', 'collection', 'user'))
        .param('progress', 'Whether to record progress on the import.',
               dataType='boolean', default=False, required=False)
        .param('leafFoldersAsItems', 'Whether folders containing only files should be '
               'imported as items.', dataType='boolean', required=False, default=False)
github girder / large_image / girder_annotation / girder_large_image_annotation / rest / annotation.py View on Github external
    @autoDescribeRoute(
        Description('Create multiple annotations on an item.')
        .modelParam('id', model=Item, level=AccessType.WRITE)
        .jsonParam('annotations', 'A JSON list of annotation model records or '
                   'annotations.  If these are complete models, the value of '
                   'the "annotation" key is used and the other information is '
                   'ignored (such as original creator ID).', paramType='body')
        .errorResponse('ID was invalid.')
        .errorResponse('Write access was denied for the item.', 403)
        .errorResponse('Invalid JSON passed in request body.')
        .errorResponse("Validation Error: JSON doesn't follow schema.")
    )
    @access.user
    def createItemAnnotations(self, item, annotations):
        user = self.getCurrentUser()
        if not isinstance(annotations, list):
            annotations = [annotations]
github Kitware / HPCCloud / server / hpccloud / hpccloud_plugin / simulations.py View on Github external
    @autoDescribeRoute(
        Description('Get a simulation')
        .modelParam('id', 'The simulation to get.',
                    model='simulation', plugin='hpccloud', level=AccessType.READ)
    )
    @access.user
    def get(self, simulation, params):
        return simulation
github girder / girder / girder / api / v1 / folder.py View on Github external
    @autoDescribeRoute(
        Description('Get the access control list for a folder.')
        .responseClass('Folder')
        .modelParam('id', model=FolderModel, level=AccessType.ADMIN)
        .errorResponse('ID was invalid.')
        .errorResponse('Admin access was denied for the folder.', 403)
    )
    def getFolderAccess(self, folder):
        return self._model.getFullAccessList(folder)
github Kitware / HPCCloud / server / hpccloud / hpccloud_plugin / projects.py View on Github external
    @autoDescribeRoute(
        Description('Share a give project with a set of users or groups')
        .modelParam('id', 'The project to be shared.',
                    model='project', plugin='hpccloud', level=AccessType.READ)
    )
    @access.user
    def get_access(self, project):
        return project.get('access', {'groups': [], 'users': []})
github Kitware / cumulus / girder / cluster_filesystem / cluster_filesystem / __init__.py View on Github external
@autoDescribeRoute(
    Description('Fetches information about a path on the clusters filesystem.')
    .modelParam('id', 'The cluster id',
                model=Cluster, destName='cluster',
                level=AccessType.READ, paramType='path')
    .param('path', 'The filesystem path.', required=True, paramType='query')
)


def _get_path(cluster, path):
    basename = os.path.basename(path)
    token = getCurrentToken()

    with get_connection(token['_id'], cluster) as conn:
        entry = conn.stat(path)

        entry_id = _generate_id(cluster['_id'], path)
github girder / girder / girder / api / v1 / file.py View on Github external
    @autoDescribeRoute(
        Description('Cancel a partially completed upload.')
        .modelParam('id', model=Upload)
        .errorResponse('ID was invalid.')
        .errorResponse('You lack permission to cancel this upload.', 403)
    )
    def cancelUpload(self, upload):
        user = self.getCurrentUser()

        if upload['userId'] != user['_id'] and not user['admin']:
            raise AccessException('You did not initiate this upload.')

        Upload().cancelUpload(upload)
        return {'message': 'Upload canceled.'}
github girder / girder / plugins / user_quota / girder_user_quota / quota.py View on Github external
    @autoDescribeRoute(
        Description('Get quota and assetstore policies for the user.')
        .modelParam('id', 'The user ID', model=User, level=AccessType.ADMIN)
        .errorResponse('ID was invalid.')
    )
    def getUserQuota(self, user):
        if QUOTA_FIELD not in user:
            user[QUOTA_FIELD] = {}
        user[QUOTA_FIELD]['_currentFileSizeQuota'] = self._getFileSizeQuota('user', user)
        return self._filter('user', user)
github girder / large_image / girder_annotation / girder_large_image_annotation / rest / annotation.py View on Github external
    @autoDescribeRoute(
        Description('Get all annotations for an item.')
        .notes('This returns a list of annotation model records.')
        .modelParam('id', model=Item, level=AccessType.READ)
        .errorResponse('ID was invalid.')
        .errorResponse('Read access was denied for the item.', 403)
    )
    @access.public(cookie=True)
    def getItemAnnotations(self, item):
        user = self.getCurrentUser()
        query = {'_active': {'$ne': False}, 'itemId': item['_id']}

        def generateResult():
            yield b'['
            first = True
            for annotation in Annotation().find(query, limit=0, sort=[('_id', 1)]):
                if not first:
github girder / girder / girder / api / v1 / item.py View on Github external
    @autoDescribeRoute(
        Description('Set metadata fields on an item.')
        .responseClass('Item')
        .notes('Set metadata fields to null in order to delete them.')
        .modelParam('id', model=ItemModel, level=AccessType.WRITE)
        .jsonParam('metadata', 'A JSON object containing the metadata keys to add',
                   paramType='body', requireObject=True)
        .param('allowNull', 'Whether "null" is allowed as a metadata value.', required=False,
               dataType='boolean', default=False)
        .errorResponse(('ID was invalid.',
                        'Invalid JSON passed in request body.',
                        'Metadata key name was invalid.'))
        .errorResponse('Write access was denied for the item.', 403)
    )
    def setMetadata(self, item, metadata, allowNull):
        return self._model.setMetadata(item, metadata, allowNull=allowNull)