def PUT(self, exception_id): """ Approve/Reject an execption. HTTP Success: 201 Created HTTP Error: 400 Bad Request 401 Unauthorized 404 Not Found 500 Internal Error """ json_data = data() try: params = loads(json_data) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: state = params['state'] except KeyError: state = None try: update_exception(exception_id=exception_id, state=state, issuer=ctx.env.get('issuer')) except UnsupportedOperation as error: raise generate_http_error(400, 'UnsupportedOperation', error[0][0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0][0]) except LifetimeExceptionNotFound as error: raise generate_http_error(404, 'LifetimeExceptionNotFound', error[0][0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) raise Created()
def put(self, exception_id): """ Approve/Reject an execption. .. :quickref: LifetimeExceptionId; Approve/reject exception. :param exception_id: The exception identifier. :<json string state: the new state (APPROVED/REJECTED) :status 201: Created. :status 400: Cannot decode json parameter list. :status 401: Invalid Auth Token. :status 404: Lifetime Exception Not Found. """ parameters = json_parameters() state = param_get(parameters, 'state', default=None) try: update_exception(exception_id=exception_id, state=state, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except UnsupportedOperation as error: return generate_http_error_flask(400, error) except AccessDenied as error: return generate_http_error_flask(401, error) except LifetimeExceptionNotFound as error: return generate_http_error_flask(404, error) return 'Created', 201
def put(self, exception_id): """ --- summary: Approve/Reject exception description: Approve/Reject a Lifetime Exception. tags: - Lifetime Exceptions parameters: - name: exception_id in: path description: The id of the Lifetime Exception. schema: type: string style: simple requestBody: content: application/json: schema: type: object properties: state: description: The new state for the Lifetime Exception. type: string enum: ['A', 'R'] responses: 201: description: OK content: application/json: schema: type: string enum: ['Created'] 401: description: Invalid Auth Token 404: description: Lifetime Exception not found 400: description: Cannot decode json parameter list. """ parameters = json_parameters() state = param_get(parameters, 'state', default=None) try: update_exception(exception_id=exception_id, state=state, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except UnsupportedOperation as error: return generate_http_error_flask(400, error) except AccessDenied as error: return generate_http_error_flask(401, error) except LifetimeExceptionNotFound as error: return generate_http_error_flask(404, error) return 'Created', 201
def put(self, exception_id): """ Approve/Reject an execption. .. :quickref: LifetimeExceptionId; Approve/reject exception. :param exception_id: The exception identifier. :<json string state: the new state (APPROVED/REJECTED) :status 201: Created. :status 400: Cannot decode json parameter list. :status 401: Invalid Auth Token. :status 404: Lifetime Exception Not Found. :Status 500: Internal Error. """ json_data = request.data try: params = loads(json_data) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: state = params['state'] except KeyError: state = None try: update_exception(exception_id=exception_id, state=state, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except UnsupportedOperation as error: return generate_http_error_flask(400, 'UnsupportedOperation', error.args[0]) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', error.args[0]) except LifetimeExceptionNotFound as error: return generate_http_error_flask(404, 'LifetimeExceptionNotFound', 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 'Created', 201