Coverage for girder/api/v1/collection : 77%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*-
############################################################################### # Copyright 2013 Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ###############################################################################
"""API Endpoint for collections."""
params['text'], user=user, limit=limit, project={ 'name': 1 })
limit=limit, sort=sort) Description('List or search for collections.') .responseClass('Collection') .param('text', "Pass this to perform a text search for collections.", required=False) .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'))
"""Create a new collection. Requires global admin."""
name=params['name'], description=params.get('description'), public=public, creator=user)
Description('Create a new collection.') .responseClass('Collection') .param('name', 'Name for the collection. Must be unique.') .param('description', 'Collection description.', required=False) .param('public', 'Public read access flag.', dataType='boolean') .errorResponse() .errorResponse('You are not an administrator', 403))
def getCollection(self, coll, params): Description('Get a collection by ID.') .responseClass('Collection') .param('id', 'The ID of the collection.', paramType='path') .errorResponse('ID was invalid.') .errorResponse('Read permission denied on the collection.', 403))
def getCollectionAccess(self, coll, params): return self.model('collection').getFullAccessList(coll) Description('Get the access control list for a collection.') .param('id', 'The ID of the collection.', paramType='path') .errorResponse('ID was invalid.') .errorResponse('Admin permission denied on the collection.', 403))
def updateCollectionAccess(self, coll, params): self.requireParams(('access',), params)
public = params.get('public', '').lower() == 'true' self.model('collection').setPublic(coll, public)
try: access = json.loads(params['access']) return self.model('collection').setAccessList( coll, access, save=True) except ValueError: raise RestException('The access parameter must be JSON.') Description('Set the access control list for a collection.') .param('id', 'The ID of the collection.', paramType='path') .param('access', 'The access control list as JSON.') .errorResponse('ID was invalid.') .errorResponse('Admin permission denied on the collection.', 403))
def updateCollection(self, coll, params): coll['name'] = params.get('name', coll['name']).strip() coll['description'] = params.get( 'description', coll['description']).strip()
coll = self.model('collection').updateCollection(coll) return self.model('collection').filter(coll) Description('Edit a collection by ID.') .responseClass('Collection') .param('id', 'The ID of the collection.', paramType='path') .param('name', 'Unique name for the collection.', required=False) .param('description', 'Collection description.', required=False) .param('public', 'Public read access flag.', dataType='boolean') .errorResponse('ID was invalid.') .errorResponse('Write permission denied on the collection.', 403))
def deleteCollection(self, coll, params): Description('Delete a collection by ID.') .param('id', 'The ID of the collection.', paramType='path') .errorResponse('ID was invalid.') .errorResponse('Admin permission denied on the collection.', 403)) |