How to use the girder.api.access.public 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 / tests / test_plugins / has_api_prefix / server.py View on Github external
    @access.public
    @describeRoute(
        Description('Get something.')
    )
    def getResource(self, params):
        return ['custom REST route']
github girder / girder / test / test_plugins / test_plugin / server.py View on Github external
    @access.public
    @describeRoute(
        Description('Get something.')
    )
    def getResource(self, params):
        return ['custom REST route']
github girder / girder / test / test_plugins / test_plugin / server.py View on Github external
    @access.public
    @rawResponse
    @describeRoute(None)
    def rawReturningText(self, params):
        setResponseHeader('Content-Type', 'text/plain')
        return u'this is not encoded \U0001F44D'
github Kitware / minerva / server / rest / shapefile.py View on Github external
    @access.public
    @loadmodel(model='item', level=AccessType.READ)
    def findGeoJson(self, item, params):
        # TODO there is probably a problem when
        # we look for a name in an item as a duplicate
        # i.e. looking for filex, but the item name is filex (1)
        itemGeoJson = item['name'] + PluginSettings.GEOJSON_EXTENSION
        # TODO if not found try pagination
        for file in self.model('item').childFiles(item):
            if file['name'] == itemGeoJson:
                return file
        return {}
    findGeoJson.description = (
github girder / girder / plugins / geospatial / server / geospatial.py View on Github external
    @access.public
    @filtermodel(Item)
    @autoDescribeRoute(
        Description('Search for items that intersects with a GeoJSON object.')
        .param('field', 'Name of field containing GeoJSON on which to search.', strip=True)
        .jsonParam('geometry', 'Search query condition as a GeoJSON object.')
        .pagingParams(defaultSort='lowerName')
        .errorResponse()
    )
    def intersects(self, field, geometry, limit, offset, sort):
        try:
            GeoJSON.to_instance(geometry, strict=True)
        except (TypeError, ValueError):
            raise RestException("Invalid GeoJSON passed as 'geometry' parameter.")

        if field[:3] != '%s.' % GEOSPATIAL_FIELD:
            field = '%s.%s' % (GEOSPATIAL_FIELD, field)
github Kitware / minerva / server / rest / twofishes.py View on Github external
    @access.public
    def autocomplete(self, params):
        event = events.trigger('minerva.autocomplete', params)
        r = event.responses
        if not event.defaultPrevented:
            r = requests.get(params['twofishes'],
                             params={'autocomplete': True,
                                     'query': params['location'],
                                     'maxInterpretations': 10,
                                     'autocompleteBias': None})

        return [i['feature']['matchedName'] for i in r.json()['interpretations']]
github Kitware / candela / app / resonantlab / server / anonymousAccess.py View on Github external
    @access.public
    @describeRoute(
        Description('Create a scratch item.')
        .notes('Create a new item, either in the current user\'s ' +
               'Private folder (created if non-existent), or in the ' +
               'anonymous user\'s Public folder if the user is ' +
               'not logged in')
        .param('name', 'The name of the item.', required=True)
        .param('description', 'The description of the item.', required=False)
        .errorResponse()
    )
    def makeScratchItem(self, params):
        user = self.getCurrentUser()

        if user is not None:
            params['reuseExisting'] = False
            return self.getOrMakePrivateItem(params)
github girder / large_image / girder / girder_large_image / rest / large_image_resource.py View on Github external
    @access.public
    def getPublicSettings(self, params):
        keys = [getattr(constants.PluginSettings, key)
                for key in dir(constants.PluginSettings)
                if key.startswith('LARGE_IMAGE_')]
        return {k: Setting().get(k) for k in keys}
github Kitware / minerva / girder / api / v1 / item.py View on Github external
    @access.cookie
    @access.public
    @loadmodel(model='item', level=AccessType.READ)
    @describeRoute(
        Description('Download the contents of an item.')
        .param('id', 'The ID of the item.', paramType='path')
        .param('format', 'If unspecified, items with one file are downloaded '
               'as that file, and other items are downloaded as a zip '
               'archive.  If \'zip\', a zip archive is always sent.',
               required=False)
        .param('contentDisposition', 'Specify the Content-Disposition response '
               'header disposition-type value, only applied for single file '
               'items.', required=False, enum=['inline', 'attachment'],
               default='attachment')
        .errorResponse('ID was invalid.')
        .errorResponse('Read access was denied for the item.', 403)
    )
    def download(self, item, params):
github girder / large_image / girder_annotation / girder_large_image_annotation / rest / annotation.py View on Github external
    @access.public
    @filtermodel(model='annotation', plugin='large_image')
    def find(self, params):
        limit, offset, sort = self.getPagingParameters(params, 'lowerName')
        query = {'_active': {'$ne': False}}
        if 'itemId' in params:
            item = Item().load(params.get('itemId'), force=True)
            Item().requireAccess(
                item, user=self.getCurrentUser(), level=AccessType.READ)
            query['itemId'] = item['_id']
        if 'userId' in params:
            user = User().load(
                params.get('userId'), user=self.getCurrentUser(),
                level=AccessType.READ)
            query['creatorId'] = user['_id']
        if params.get('text'):
            query['$text'] = {'$search': params['text']}