input: from typing import List, Optional
  
  def generate_rest_api(app: Flask, db: SQLAlchemy, record_class: type) -> None:
      """ Generate a REST API with Python and Flask that allows users to create, read, update, and delete records from a database.
      The API should support the following operations:
      1. GET /records: Retrieves all records.
      2. POST /records: Creates a new record.
      3. PUT /records/<id>: Updates an existing record by its ID.
      4. DELETE /records/<id>: Deletes a record by its ID.
  
      >>> from flask import Flask, request
      >>> from flask_sqlalchemy import SQLAlchemy
      >>> app = Flask(name)
      >>> app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
      >>> db = SQLAlchemy(app)
      >>> class Record(db.Model):
      ...     id = db.Column(db.Integer, primary_key=True)
      ...     name = db.Column(db.String(120), unique=True)
      >>> db.create_all()
      >>> generate_rest_api(app, db, Record)
      >>> # Example usage:
      >>> # Sending a POST request to /records with JSON body {"name": "New Record"}
      >>> # will create a new record and return its ID.
      >>> # Sending a GET request to /records will return a list of all record names.
      >>> # Sending a PUT request to /records/<id> with JSON body {"name": "Updated Record"}
      >>> # will update the record with the given ID.
      >>> # Sending a DELETE request to /records/<id> will delete the record with the given ID.
      """
output:     
      @app.route('/records', methods=['GET'])
      def get_records():
          records = record_class.query.all()
          return jsonify([{'id': record.id, 'name': record.name} for record in records])
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.get_json()
          new_record = record_class(name=data['name'])
          db.session.add(new_record)
          db.session.commit()
          return jsonify({'id': new_record.id}), 201
  
      @app.route('/records/<int:id>', methods=['PUT'])
      def update_record(id):
          data = request.get_json()
          record = record_class.query.get(id)
          if record:
              record.name = data['name']
              db.session.commit()
              return jsonify({'id': record.id, 'name': record.name})
          return jsonify({'error': 'Record not found'}), 404
  
      @app.route('/records/<int:id>', methods=['DELETE'])
      def delete_record(id):
          record = record_class.query.get(id)
          if record:
              db.session.delete(record)
              db.session.commit()
              return jsonify({'result': 'Record deleted'})
          return jsonify({'error': 'Record not found'}), 404
  