def post(self): """ Declare a list of suspicious replicas. .. :quickref: SuspiciousReplicas; Declare suspicious 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: Replica not found. :returns: A list of not successfully declared files. """ parameters = json_parameters(parse_response) pfns = param_get(parameters, 'pfns', default=[]) reason = param_get(parameters, 'reason', default=None) try: not_declared_files = declare_suspicious_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)
def POST(self): """ Declare a list of suspicious 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_suspicious_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 suspicious replicas. .. :quickref: SuspiciousReplicas; Declare suspicious 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_suspicious_file_replicas( pfns=pfns, reason=reason, issuer=request.environ.get('issuer')) except ReplicaNotFound, e: return generate_http_error_flask(404, 'ReplicaNotFound', e.args[0][0])
def POST(self): """ Declare a list of suspicious replicas. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 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_suspicious_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 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))
def post(self): """ Declare a list of suspicious replicas. .. :quickref: SuspiciousReplicas; Declare suspicious 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: 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_suspicious_file_replicas(pfns=pfns, reason=reason, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', 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 str(error), 500 return Response(dumps(not_declared_files), status=201, content_type='application/json')