old_contents: """ Base classes and data for building the API """
  from flask_restful import reqparse, Resource
  
  from .util import clean_attrs, set_attrs
  from dockci.server import DB
  
  
  AUTH_FORM_LOCATIONS = ('form', 'headers', 'json')
  
  
  class BaseDetailResource(Resource):
      """ Base resource for details API endpoints """
      # pylint:disable=no-self-use
      def handle_write(self, model, parser=None, data=None):
          """ Parse request args, set attrs on the model, and commit """
          assert parser is not None or data is not None, (
              "Must give either parser, or data")
  
          if data is None:
              args = parser.parse_args(strict=True)
              args = clean_attrs(args)
          else:
              args = data
  
          set_attrs(model, args)
          DB.session.add(model)
          DB.session.commit()
          return model
  
  
  class BaseRequestParser(reqparse.RequestParser):
      """
      Request parser that should be used for all DockCI API endpoints. Adds
      ``username``, ``password``, and ``api_key`` fields for login
      """
      def __init__(self, *args, **kwargs):
          super(BaseRequestParser, self).__init__(*args, **kwargs)
          self.add_argument('username', location=AUTH_FORM_LOCATIONS)
          self.add_argument('password', location=AUTH_FORM_LOCATIONS)
          self.add_argument('api_key', location=('args',) + AUTH_FORM_LOCATIONS)
  
new_contents: """ Base classes and data for building the API """
  from flask_restful import reqparse, Resource
  
  from .util import clean_attrs, set_attrs
  from dockci.server import DB
  
  
  AUTH_FORM_LOCATIONS = ('form', 'json')
  
  
  class BaseDetailResource(Resource):
      """ Base resource for details API endpoints """
      # pylint:disable=no-self-use
      def handle_write(self, model, parser=None, data=None):
          """ Parse request args, set attrs on the model, and commit """
          assert parser is not None or data is not None, (
              "Must give either parser, or data")
  
          if data is None:
              args = parser.parse_args(strict=True)
              args = clean_attrs(args)
          else:
              args = data
  
          set_attrs(model, args)
          DB.session.add(model)
          DB.session.commit()
          return model
  
  
  class BaseRequestParser(reqparse.RequestParser):
      """
      Request parser that should be used for all DockCI API endpoints. Adds
      ``username``, ``password``, and ``api_key`` fields for login
      """
      def __init__(self, *args, **kwargs):
          super(BaseRequestParser, self).__init__(*args, **kwargs)
          self.add_argument('username', location=AUTH_FORM_LOCATIONS)
          self.add_argument('password', location=AUTH_FORM_LOCATIONS)
          self.add_argument('api_key', location=('args',) + AUTH_FORM_LOCATIONS)
          self.add_argument('X-Dockci-Username',
                            location='headers',
                            dest='username')
          self.add_argument('X-Dockci-Password',
                            location='headers',
                            dest='password')
          self.add_argument('X-Dockci-Api-Key',
                            location='headers',
                            dest='api_key')
  
subject: Fix auth headers