def POST(self, rse): """ Get files metadata at a given RSE. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 500 Internal Error """ header('Content-Type', 'application/json') json_data = data() try: parameters = parse_response(json_data) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: url = parameters['url'] new_url = parameters['new_url'] objectstore.rename(url, new_url, rse=rse) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(traceback.format_exc()) raise InternalError(error) raise OK()
def post(self, rse): """ Rename object. .. :quickref: ObjectStoreRename; Rename object. :param rse: the RSE name. :<json string url: the URL string. :<json string new_url: the new URL string. :<json string urls: A list of URL string. :resheader Content-Type: application/json :status 200: OK. :status 400: Cannot decode json parameter list. :status 401: Invalid Auth Token. :status 500: Internal Error. """ json_data = request.data try: parameters = parse_response(json_data) except ValueError: return generate_http_error_flask(400, 'ValueError', 'Cannot decode json parameter list') try: url = parameters['url'] new_url = parameters['new_url'] objectstore.rename(url, new_url, rse=rse) except RucioException, e: return generate_http_error_flask(500, e.__class__.__name__, e.args[0][0])
def test_rename(self): """ OBJECTSTORE (COMMON): Rename """ url = self.url new_url = '%s_new' % url objectstore.rename(url, new_url, rse=self.rse) ret = objectstore.get_metadata([url], rse=self.rse) if not isinstance(ret[url], exception.SourceNotFound): raise ret[url] ret = objectstore.get_metadata([new_url], rse=self.rse) if isinstance(ret[new_url], Exception): raise ret[new_url] if 'filesize' not in ret[new_url]: raise Exception("Respone not as expected: should return {'filesize': filesize}, but it returns: %s" % ret[url])