-
Install docker and kubectl.
-
Install minikube https://kubernetes.io/docs/tasks/tools/install-minikube/. This requires you to also install a hypervisor. I went ahead with kvm-qemu. This requires Intel Virtualisation to be enabled from BIOS.
-
Start minikube with
minikube start
-
Run
kubectl apply -f k8s-configs
-
Git clone the repo
https://github.com/maheshgudi/moviedb
or via ssh throughgit@github.com:maheshgudi/moviedb.git
-
Set-up and activate a python3 virtualenv. preferably python3.7.6 or higher. Run
pip install -r requirements.txt
to install dependencies. -
Run the server by running the command
python manage.py runserver
. Run migrations beforehand. -
Run the following command to upload sample files.
python manage.py upload_movies movie_file movies/imdb.json
-
Create superuser using the command
python manage.py createsuperuser
. -
Login into the admin panel and create a group
Administrator
with all permissions forMovie
Model. -
Admin can add registered users into the
Administrator
group. The user can then be able to create, delete, and update movie from API endpoints. -
Admin password is
username-admin, password-admin
to access the heroku server for the same. -
Heroku API server can be found on the following https://django-moviedb.herokuapp.com/
This server acts as a REST API server to search, add, edit and delete database of movies.
Returns the OpenAPI Schema
for the API. This is useful to discover and understand the capabilities of the service.
Login into the Django admin panel. All models are registered in the admin page.
Add following JSON Fields in the POST Body.
{
"username": "<username>",
"email": "<email>",
"password": "<password>",
"first_name": "<first_name>",
"last_name": "<last_name>"
}
If Username
and/or email
is not registered previously, User is created and token is returned, as shown below,
{'token': <token_id>,
'status': True,
'message': 'User created successfully'}
Note: Please save the token and use it in the headers for all future API calls.
Note: User needs to be registered to be able to access this feature.
Add in JSON request Header
{'Authorization': 'token <token_id>'}
Returns all movies stored in the db as in JSON
format.
Note: User needs to be an admin and have a admin token to be able to access this feature.
Add in JSON request Header
{'Authorization': 'token <token_id>'}
Returns the Movie details.
{
"status":true,
"movie_id":"74826d60-6c42-4221-86a9-d283ed6f6946",
"name":"The Wizard of Oz",
"director":"Victor Fleming",
"imdb_score":8.3,
"popularity":83.0,
"genres":["Adventure","Family","Fantasy","Musical"]
}
Add in JSON request Header
{'Authorization': 'token <token_id>'}
Returns the deleted movie details.
{
"status":true,
"message":"<movie_name> deleted successfully"
}
Add in JSON request Header
{'Authorization': 'token <token_id>'}
and add in PUT body
{
"movie_id":"74826d60-6c42-4221-86a9-d283ed6f6946",
"name":"The Wizard of Oz",
"director":"Victor Fleming, Mahesh Gudi",
"imdb_score":8.3,
"popularity":83.0,
"genres":["Adventure","Family","Fantasy","Musical"]
}
NOTE: Director name is being updated with this POST Body. One can ignore movie_id while posting.
If however, one does add a movie id, it will still not update the original movie id.
Returns the Movie details.
{
"status":true,
"movie_id":"74826d60-6c42-4221-86a9-d283ed6f6946",
"name":"The Wizard of Oz",
"director":"Victor Fleming, Mahesh Gudi",
"imdb_score":8.3,
"popularity":83.0,
"genres":["Adventure","Family","Fantasy","Musical"]
}
Add in JSON request Header
{'Authorization': 'token <token_id>'}
and add in POST body
[
{
"99popularity": 83.0,
"director": "Mahesh Gudi",
"genre": [
"Adventure",
" Family",
" Fantasy",
" Musical"
],
"imdb_score": 8.3,
"name": "The Wizard of Oz"
},
{
"99popularity": 88.0,
"director": "Mahesh Gudi",
"genre": [
"Action",
" Adventure",
" Fantasy",
" Sci-Fi"
],
"imdb_score": 8.8,
"name": "Star Wars"
}
]
Returns the Movie details.
{'status': True,
'data': [{'movie_id': 'da00e02a-7b8b-4aeb-af48-60e35c2d7d41',
'name': 'The Wizard of Oz',
'director': 'Mahesh Gudi',
'imdb_score': 8.3,
'popularity': 83.0,
'genres': ['Adventure', 'Family', 'Fantasy', 'Musical']},
{'movie_id': '235835bb-33fa-48d5-aafc-4412930ecbda',
'name': 'Star Wars',
'director': 'Mahesh Gudi',
'imdb_score': 8.8,
'popularity': 88.0,
'genres': ['Adventure', 'Fantasy', 'Action', 'Sci-Fi']}]}
Note: Any user can search for movies. No authentication token required.
Search for the following get parameters i.e. name, director, imdb_score, popularity, genre
. One can search with only one params or even many.
Each param can have only one value.
For e.g. -
GET /api/search/?director=martin
will return
{
"status": true,
"data": [
{
"movie_id": "f11ec718-ee06-4175-9bc4-be093e37ec18",
"name": "Taxi Driver",
"director": "Martin Scorsese",
"imdb_score": 8.6,
"popularity": 86.0,
"genres": [
"Drama",
"Thriller"
]
},
{
"movie_id": "b3c3ac74-915c-4107-8273-25f1494b2d78",
"name": "Goodfellas",
"director": "Martin Scorsese",
"imdb_score": 8.8,
"popularity": 88.0,
"genres": [
"Drama",
"Thriller",
"Crime"
]
}
]
}
While adding more query params
GET /api/search/?director=martin?name=good
will return
{
"status": true,
"data": [
{
"movie_id": "b3c3ac74-915c-4107-8273-25f1494b2d78",
"name": "Goodfellas",
"director": "Martin Scorsese",
"imdb_score": 8.8,
"popularity": 88.0,
"genres": [
"Drama",
"Thriller",
"Crime"
]
}
]
}