The Casting Agency models a company that is responsible for creating movies and managing and assigning actors to those movies. You are an Executive Producer within the company and are creating a system to simplify and streamline your process.
- Get Actors
- Save Actors to Database
- Update Actors
- Delete Actors
- Get Movies
- Insert Movie to Database
- Update Movie
- Delete Movie
Base URL: https://casting-agency-udacity.herokuapp.com/
- SQLAlchemy ORM to be our ORM library of choice
- PostgreSQL as our database of choice
- Python3 and Flask as our server language and server framework
- Flask-Migrate for creating and running schema migrations
- Initialize and Setup virtual environment
py -m venv venv
- Active the virtual environment
source venv/bin/activate
- Install the dependencies:
$ pip install -r requirements.txt
Adjust the database settings in the config.py file with the postgres installed on your local computer
db_setting = {
"db_name" : "casting_agency",
"username" : "postgres",
"password" : "postgres",
"port" : "localhost:5432"
}
Running migrations using our manage.py file.
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
To run the server, execute:
python app.py
- Create a new Auth0 Account
- Select a unique tenant domain
- Create a new, single page web application
- Create a new API
- in API Settings:
- Enable RBAC
- Enable Add Permissions in the Access Token
- in API Settings:
- Create new API permissions:
get:actors
post:actors
patch:actors
delete:actors
get:movies
post:movies
patch:movies
delete:movies
- Create new roles for:
- Casting Assistant
- can
get:actors
- can
get:movies
- can
- Casting Director
- can
delete:actors
- can
get:actors
- can
get:movies
- can
patch:actors
- can
patch:movies
- can
post:actors
- can
- Executive Producer
- can
delete:actors
- can
delete:movies
- can
get:actors
- can
get:movies
- can
patch:actors
- can
patch:movies
- can
post:actors
- can
post:movies
- can perform all actions
- can
- Casting Assistant
To run the tests, run
python test_app.py
- Base URL: The backend is hosted at
https://casting-agency-udacity.herokuapp.com/
- Authentication: This version require authentication or API keys.
Errors are returned as JSON in the following format:
{
"success": False,
"error": 404,
"message": "resource not found"
}
-
General: Returns a list actors.
-
Sample:
curl --request GET 'https://casting-agency-udacity.herokuapp.com/actors' -H "Authorization: Bearer ${TOKEN}"
{ "actors": [ { "age": 32, "gender": "Male", "id": 1, "name": "Jack Torrance" } ], "success": true }
-
General: Creates a actor using JSON Body.
-
Sample:
curl -d '{"name": "Rose", "age": "20", "gender": "Female"}' -X POST https://casting-agency-udacity.herokuapp.com/actors -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"
{ "created": 3, "success": true }
-
General: Update actor.
-
Sample:
curl -d '{"age": "45"}' -X PATCH https://casting-agency-udacity.herokuapp.com/actors/1 -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"
{ "actor": [ { "age": 45, "gender": "Male", "id": 1, "name": "Jack Torrance" } ], "success": true, "updated": 1 }
-
General: Delete actor.
-
Sample:
curl -X DELETE https://casting-agency-udacity.herokuapp.com/actors/1 -H "Authorization: Bearer ${TOKEN}"
{ "deleted":"1", "success":true }
-
General: Returns a list movies.
-
Sample:
curl --request GET 'https://casting-agency-udacity.herokuapp.com/movies' -H "Authorization: Bearer ${TOKEN}"
{ "movies":[ { "id":1, "release_date":"Fri, 10 Apr 2020 00:00:00 GMT", "title":"The Shinning" }, { "id":2, "release_date":"Fri, 10 Apr 2020 00:00:00 GMT", "title":"Pycsho" } ], "success":true }
-
General: Creates a movie using JSON Body.
-
Sample:
curl -d '{"title": "Hysteria", "release_date": "2020-04-10"}' -X POST https://casting-agency-udacity.herokuapp.com/movies -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"
{ "created": 3, "success": true }
-
General: Update movie.
-
Sample:
curl -d '{"title": "The Shining Extended"}' -X PATCH https://casting-agency-udacity.herokuapp.com/movies/1 -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"
{ "edited":1, "movie":[ { "id":1, "release_date":"Fri, 10 Apr 2020 00:00:00 GMT", "title":"The Shining Extended" } ], "success":true }
-
General: Delete actor.
-
Sample:
curl -X DELETE https://casting-agency-udacity.herokuapp.com/movies/1 -H "Authorization: Bearer ${TOKEN}"
{ "deleted":"1", "success":true }