def post(self): """ Declare a list of bad PFNs. .. :quickref: BadPFNs; Declare bad replicas. :<json string pfns: The list of PFNs. :<json string reason: The reason of the loss. :<json string state: The state is eiher BAD, SUSPICIOUS or TEMPORARY_UNAVAILABLE. :<json string expires_at: The expiration date. Only apply to TEMPORARY_UNAVAILABLE. :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 = [] reason = None state = None expires_at = None try: params = parse_response(json_data) if 'pfns' in params: pfns = params['pfns'] if 'reason' in params: reason = params['reason'] if 'reason' in params: reason = params['reason'] if 'state' in params: reason = params['state'] if 'expires_at' in params: expires_at = datetime.strptime(params['expires_at'], "%Y-%m-%dT%H:%M:%S.%f") add_bad_pfns(pfns=pfns, issuer=request.environ.get('issuer'), state=state, reason=reason, expires_at=expires_at, vo=request.environ.get('vo')) except (ValueError, InvalidType) as error: return generate_http_error_flask(400, 'ValueError', error.args[0]) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', error.args[0]) except ReplicaNotFound as error: return generate_http_error_flask(404, 'ReplicaNotFound', error.args[0]) except Duplicate as error: return generate_http_error_flask(409, 'Duplicate', 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 'Created', 201
def POST(self): """ Declare a list of bad PFNs. HTTP Success: 200 OK HTTP Error: 400 BadRequest 401 Unauthorized 409 Conflict 500 InternalError """ json_data = data() pfns = [] reason = None state = None expires_at = None 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'] if 'state' in params: state = params['state'] if 'expires_at' in params and params['expires_at']: expires_at = datetime.strptime(params['expires_at'], "%Y-%m-%dT%H:%M:%S.%f") add_bad_pfns(pfns=pfns, issuer=ctx.env.get('issuer'), state=state, reason=reason, expires_at=expires_at, vo=ctx.env.get('vo')) except (ValueError, InvalidType) as error: raise generate_http_error(400, 'ValueError', error.args[0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except ReplicaNotFound as error: raise generate_http_error(404, 'ReplicaNotFound', error.args[0]) except Duplicate as error: raise generate_http_error(409, 'Duplicate', 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()
def post(self): """ Declare a list of bad PFNs. .. :quickref: BadPFNs; Declare bad replicas. :<json string pfns: The list of PFNs. :<json string reason: The reason of the loss. :<json string state: The state is eiher BAD, SUSPICIOUS or TEMPORARY_UNAVAILABLE. :<json string expires_at: The expiration date. Only apply to TEMPORARY_UNAVAILABLE. :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. :returns: A list of not successfully declared files. """ parameters = json_parameters(parse_response) expires_at = param_get(parameters, 'expires_at', default=None) if expires_at: expires_at = datetime.strptime(expires_at, "%Y-%m-%dT%H:%M:%S.%f") try: add_bad_pfns( pfns=param_get(parameters, 'pfns', default=[]), issuer=request.environ.get('issuer'), state=param_get(parameters, 'state', default=None), reason=param_get(parameters, 'reason', default=None), expires_at=expires_at, vo=request.environ.get('vo'), ) except (ValueError, InvalidType) as error: return generate_http_error_flask(400, ValueError.__name__, error.args[0]) except AccessDenied as error: return generate_http_error_flask(401, error) except ReplicaNotFound as error: return generate_http_error_flask(404, error) except Duplicate as error: return generate_http_error_flask(409, error) return 'Created', 201