Flask API Using MethodView

For this assignment you will extend a Flask REST API implementation that uses a new Flask feature, the MethodView class.

The file dogs_api_views.py has starter code which implements the same API as the starter code for the last assignment, except it has added support to delete a dog. Watch this video for my discussion of this code.

NOTE: There is a typo in the post() method of BreedsView. It should be request.form['breed'], not request.form['name'].

The provided dog_db.py file is the same as the one provided for the last assignment, except it has a delete_dog() method for deleting a dog:

    def delete_dog(self, dog_id):
        """
        Delete the dog with the given primary key.

        :param dog_id: primary key of the dog
        """

        cur = self.conn.cursor()

        query = 'DELETE FROM dog WHERE dog_id = ?'
        cur.execute(query, (dog_id,))

        self.conn.commit()

For this assignment I am asking you to again add support for owners to this new codebase, and also add support for deleting breeds and owners. I recommend copying over your dog_db.py from the last assignment to the repository for this assignment, and adding the delete_dog() method shown above to your code. Then you can add delete_breed() and delete_owner().

Note that you may have to delete dogs when you delete breeds and owners. If you are deleting an owner by ID, you must first delete all of the dogs that have that owner_id, to maintain the foreign key constraint.

In dogs_api_views.py, adapt the code that you wrote for owners in dogs_api.py for the last assignment so that it uses a MethodView class instead of decorated functions. Then, add delete() methods for both the breed and the owner MethodView classes.

Requirements Summary

Here is a more condensed list of what I am asking you to do:

Push your code back to git-keeper to submit.