Coverage for girder/api/v1/assetstore : 85%

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 managing assetstores. Requires admin privileges. """
""" Get a list of assetstores.
:param limit: The result set size limit, default=50. :param offset: Offset into the results, default=0. :param sort: The field to sort by, default=name. :param sortdir: 1 for ascending, -1 for descending, default=1. """
offset=offset, limit=limit, sort=sort) Description('List assetstores.') .param('limit', "Result set size limit (default=50).", required=False, dataType='integer') .param('offset', "Offset into result set (default=0).", required=False, dataType='integer') .param('sort', "Field to sort the assetstore list by (default=name)", required=False) .param('sortdir', "1 for ascending, -1 for descending (default=1)", required=False, dataType='integer') .errorResponse() .errorResponse('You are not an administrator.', 403))
"""Create a new assetstore."""
name=params['name'], root=params['root']) return self.model('assetstore').createGridFsAssetstore( name=params['name'], db=params['db']) elif assetstoreType == AssetstoreType.S3: return self.model('assetstore').createS3Assetstore( name=params['name']) else: raise RestException('Invalid type parameter') Description('Create a new assetstore.') .responseClass('Assetstore') .notes('You must be an administrator to call this.') .param('name', 'Unique name for the assetstore.') .param('type', 'Type of the assetstore.', dataType='integer') .param('root', 'Root path on disk (for filesystem type)', required=False) .param('db', 'Database name (for GridFS type)', required=False) .errorResponse() .errorResponse('You are not an administrator.', 403))
def updateAssetstore(self, assetstore, params):
elif assetstore['type'] == AssetstoreType.GRIDFS: self.requireParams(('db',), params) assetstore['db'] = params['db']
Description('Update an existing assetstore.') .responseClass('Assetstore') .param('id', 'The ID of the assetstore.', paramType='path') .param('name', 'Unique name for the assetstore') .param('root', 'Root path on disk (for Filesystem type)', required=False) .param('db', 'Database name (for GridFS type)', required=False) .param('current', 'Whether this is the current assetstore', dataType='boolean') .errorResponse() .errorResponse('You are not an administrator.', 403))
def deleteAssetstore(self, assetstore, params): Description('Delete an assetstore.') .notes('This will fail if there are any files in the assetstore.') .param('id', 'The ID of the assetstore.', paramType='path') .errorResponse() .errorResponse('The assetstore is not empty.') .errorResponse('You are not an administrator.', 403)) |