def POST(self): """ Declare a list of bad replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 500 InternalError """ json_data = data() rse, pfns = None, [] header('Content-Type', 'application/x-json-stream') try: params = parse_response(json_data) if 'pfns' in params: pfns = params['pfns'] if 'rse' in params: rse = params['rse'] except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: declare_bad_file_replicas(rse=rse, pfns=pfns, issuer=ctx.env.get('issuer')) except ReplicaNotFound, e: raise generate_http_error(404, 'ReplicaNotFound', e.args[0][0])
def post(self): """ Declare a list of bad replicas. .. :quickref: BadReplicasStates; Declare bad replicas. :<json string pfns: The list of PFNs. :<json string reason: The reason of the loss. :resheader Content-Type: application/json :status 201: Created. :status 400: Cannot decode json parameter list. :status 401: Invalid auth token. :status 404: RSE not found. :status 404: Replica not found. :returns: A list of not successfully declared files. """ parameters = json_parameters() pfns = param_get(parameters, 'pfns', default=[]) reason = param_get(parameters, 'reason', default=None) try: not_declared_files = declare_bad_file_replicas(pfns=pfns, reason=reason, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) return not_declared_files, 201 except AccessDenied as error: return generate_http_error_flask(401, error) except (RSENotFound, ReplicaNotFound) as error: return generate_http_error_flask(404, error)
def POST(self): """ Declare a list of bad replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 500 InternalError """ json_data = data() pfns = [] header('Content-Type', 'application/x-json-stream') try: params = parse_response(json_data) if 'pfns' in params: pfns = params['pfns'] if 'reason' in params: reason = params['reason'] except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') not_declared_files = {} try: not_declared_files = declare_bad_file_replicas( pfns=pfns, reason=reason, issuer=ctx.env.get('issuer')) except ReplicaNotFound, e: raise generate_http_error(404, 'ReplicaNotFound', e.args[0][0])
def post(self): """ Declare a list of bad replicas. .. :quickref: BadReplicasStates; Declare bad replicas. :<json string pfns: The list of PFNs. :<json string reason: The reason of the loss. :resheader Content-Type: application/x-json-string :status 201: Created. :status 400: Cannot decode json parameter list. :status 401: Invalid auth token. :status 404: Replica not found. :status 500: Internal Error. :returns: A list of not successfully declared files. """ json_data = request.data pfns = [] try: params = parse_response(json_data) if 'pfns' in params: pfns = params['pfns'] if 'reason' in params: reason = params['reason'] except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') not_declared_files = {} try: not_declared_files = declare_bad_file_replicas( pfns=pfns, reason=reason, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except ReplicaNotFound as error: return generate_http_error_flask(404, 'ReplicaNotFound', error.args[0]) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) return error, 500 return Response(dumps(not_declared_files), status=201, content_type='application/x-json-stream')
def POST(self): """ Declare a list of bad replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 406 Not Acceptable 500 InternalError """ json_data = data() pfns = [] header('Content-Type', 'application/json') try: params = parse_response(json_data) if 'pfns' in params: pfns = params['pfns'] if 'reason' in params: reason = params['reason'] except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') not_declared_files = {} try: not_declared_files = declare_bad_file_replicas( pfns=pfns, reason=reason, issuer=ctx.env.get('issuer'), vo=ctx.env.get('vo')) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except RSENotFound as error: raise generate_http_error(404, 'RSENotFound', error.args[0]) except ReplicaNotFound as error: raise generate_http_error(404, 'ReplicaNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) raise Created(dumps(not_declared_files))