input: Write a function that generates a basic REST API with authentication and endpoints in Python using Flask and Flask-RESTful libraries. Include JWT authentication and provide endpoints for adding and retrieving items. The function should return the Flask application instance.
  assert generate_rest_api()
output: 
  from flask import Flask, request, jsonify
  from flask_restful import Api, Resource
  from flask_jwt_extended import JWTManager, jwt_required, create_access_token, get_jwt_identity
  
  def generate_rest_api():
      app = Flask(__name__)
      api = Api(app)
      app.config['JWT_SECRET_KEY'] = 'super-secret'
      jwt = JWTManager(app)
  
      items = []
  
      class Item(Resource):
          @jwt_required()
          def get(self, name):
              item = next(filter(lambda x: x['name'] == name, items), None)
              return {'item': item}, 200 if item else 404
  
          @jwt_required()
          def post(self, name):
              if next(filter(lambda x: x['name'] == name, items), None):
                  return {'message': "An item with name '{}' already exists.".format(name)}, 400
              data = request.get_json()
              item = {'name': name, 'price': data['price']}
              items.append(item)
              return item, 201
  
      class Login(Resource):
          def post(self):
              username = request.json.get('username', None)
              password = request.json.get('password', None)
              if not username or not password:
                  return {'message': 'Missing username or password'}, 400
              access_token = create_access_token(identity=username)
              return {'access_token': access_token}, 200
  
      api.add_resource(Item, '/item/<string:name>')
      api.add_resource(Login, '/login')
  
      return app
  