How to use the girder.api.rest.filtermodel 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
    @filtermodel(model='job', plugin='jobs')
    @describeRoute(
        Description('Test celery task delay fails correctly'))
    def test_celery_task_delay_fails(self, params):
        result = fail_after.delay()
        return result.job
github girder / girder_worker / tests / integration / integration_test_endpoints / integration_test_endpoints / docker.py View on Github external
    @filtermodel(model='job', plugin='jobs')
    @describeRoute(
        Description('Test downloading file using named pipe.'))
    def test_docker_run_girder_file_to_named_pipe(self, params):
        tmp_dir = params.get('tmpDir')
        file_id = params.get('fileId')
        mount_dir = '/mnt/girder_worker/data'
        pipe_name = 'input_pipe'

        volumes = {
            tmp_dir: {
                'bind': mount_dir,
                'mode': 'rw'
            }
        }

        connect = Connect(GirderFileIdToStream(file_id),
github girder / girder_worker / tests / integration / integration_test_endpoints / integration_test_endpoints / raw.py View on Github external
    @filtermodel(model='job', plugin='jobs')
    @describeRoute(
        Description('Test celery task apply_async fails correctly'))
    def test_celery_task_apply_async_fails(self, params):
        result = fail_after.apply_async((0.5,))
        return result.job
github girder / girder / girder / api / v1 / item.py View on Github external
    @filtermodel(model=ItemModel)
    @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)
github girder / girder / girder / api / v1 / collection.py View on Github external
    @filtermodel(CollectionModel)
    @autoDescribeRoute(
        Description('Delete metadata fields on a collection.')
        .responseClass('Collection')
        .modelParam('id', model=CollectionModel, level=AccessType.WRITE)
        .jsonParam(
            'fields', 'A JSON list containing the metadata fields to delete',
            paramType='body', schema={
                'type': 'array',
                'items': {
                    'type': 'string'
                }
            }
        )
        .errorResponse(('ID was invalid.',
                        'Invalid JSON passed in request body.',
                        'Metadata key name was invalid.'))
github girder / covalic / covalic / rest / submission.py View on Github external
    @filtermodel(model=Submission)
    @autoDescribeRoute(
        Description('Overwrite the properties of a submission.')
        .modelParam('id', 'The ID of the challenge phase to submit to.',
                    model=Submission, paramType='path', destName='submission')
        .param('title', 'Title for the submission', required=False)
        .param('date', 'The date of the submission.', required=False)
        .param('organization', 'Organization associated with the submission.',
               required=False)
        .param('organizationUrl', 'URL for organization associated with the submission.',
               required=False)
        .param('documentationUrl', 'URL of documentation associated with the submission.',
               required=False)
        .param('disqualified', 'Whether the submission is disqualified. Disqualified '
               'submissions do not appear in the leaderboard.', dataType='boolean', required=False)
        .param('approach', 'The submission approach.', required=False)
        .jsonParam('meta', 'A JSON object containing additional submission metadata. '
github girder / girder / girder / api / v1 / collection.py View on Github external
    @filtermodel(model=CollectionModel, addFields={'access'})
    @autoDescribeRoute(
        Description('Set the access control list for a collection.')
        .modelParam('id', model=CollectionModel, level=AccessType.ADMIN)
        .jsonParam('access', 'The access control list as JSON.', requireObject=True)
        .jsonParam('publicFlags', 'List of public access flags to set on the collection.',
                   required=False, requireArray=True)
        .param('public', 'Whether the collection should be publicly visible.',
               dataType='boolean', required=False)
        .param('recurse', 'Whether the policies should be applied to all '
               'folders under this collection as well.', dataType='boolean',
               default=False, required=False)
        .param('progress', 'If recurse is set to True, this controls whether '
               'progress notifications will be sent.', dataType='boolean',
               default=False, required=False)
        .errorResponse('ID was invalid.')
        .errorResponse('Admin permission denied on the collection.', 403)
github Kitware / minerva / girder / api / v1 / file.py View on Github external
    @filtermodel(model='file')
    @describeRoute(
        Description('Get a file\'s information.')
        .param('id', 'The ID of the file.', paramType='path')
        .errorResponse()
        .errorResponse('Read access was denied on the file.', 403)
    )
    def getFile(self, file, params):
        return file
github Kitware / cumulus / girder / taskflow / taskflow / taskflows.py View on Github external
    @filtermodel(model='task', plugin='taskflow')
    @loadmodel(model='taskflow', plugin='taskflow', level=AccessType.READ)
    @describeRoute(
        Description('Create a new task associated with this flow')
        .param(
            'id',
            'The id of taskflow',
            required=True, paramType='path')
        .param(
            'body',
            'The properties to update',
            required=False, paramType='body', dataType='CreateTaskParams')
    )
    def create_task(self, taskflow, params):
        user = getCurrentUser()
        task = getBodyJson()
github girder / girder / girder / api / v1 / api_key.py View on Github external
    @filtermodel(ApiKeyModel)
    @autoDescribeRoute(
        Description('Update an API key.')
        .modelParam('id', 'The ID of the API key.', model=ApiKeyModel, destName='apiKey',
                    level=AccessType.WRITE)
        .param('name', 'Name for the key.', required=False, strip=True)
        .jsonParam('scope', 'JSON list of scopes for this key.', required=False,
                   default=())
        .param('tokenDuration', 'Max number of days tokens created with this key will last.',
               required=False)
        .param('active', 'Whether the key is currently active.', required=False,
               dataType='boolean')
        .errorResponse()
    )
    def updateKey(self, apiKey, name, scope, tokenDuration, active):
        if active is not None:
            apiKey['active'] = active