Assignment from Yabonza
This code base contains following REST API endpoints.
- Creating a new dog breed record
- Retrieving an existing dog breed record , given the identity
- Deleting an existing dog breed record , given the identity
- Search a dog breed record based on the given breed name
- Find all the existing dog breeds , page by page
This project runs of SpringBoot , hence JAVA 1.8 must be used to run the project
This is a generic Maven project. Clone the source code and navigate to the root folder. Execute following commands for building the application
1. mvn clean - For cleaning the project
2. mvn package - for packaging the project
3. mvn spring-boot:run - for running the project during the development
mvn package
- This command would package the project as a
runnable jar file. Once the jar file is created execute the following
command to run the project.
java -jar petdogs-0.0.1-SNAPSHOT.jar
[make sure the path to the file name is accurate]
It must be noted that when the project is started following environmental variables must be provided in order to access AWS S3 bucket.
export AWS_SECRET_ACCESS_KEY=[secret access key]
export AWS_ACCESS_KEY_ID=[access key id]
In order to change the database change the database connection properties in the following file.
petdogs-db.properties
petdogs.datasource.jdbcUrl=jdbc:mysql://localhost:3306/[yourschemaname]?serverTimezone=UTC
petdogs.datasource.username=***
petdogs.datasource.password=***
For re-creating the tables following property key must be changed to the approriate value.
use validate | update | create | create-drop
hibernate.hbm2ddl.auto=update
The AWS S3 bucket policy is configured in such a way that the annonymous access is allowed.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::petdog-bucket/*"
]
}
]
}
Api Endpoing signature :
http://[host]:[port]/petdogs/dogs
Supported HTTP method :Only PUT
Example Response:
{ "message": "A new random dog breed is created.", "status": "success", "id": 11, "breed": "schnauzer-giant", "createdOn": "2019-01-21T14:05:31.621+11:00[Australia/Sydney]", "accessUrl": "https://s3.amazonaws.com/petdog-bucket/3a2a36a4-65bc-4617-8cb6-c321eb52ce09.jpg" }
Api Endpoing signature :
http://[host]:[port]/petdogs/dogs/{id}
Supported HTTP method :Only GET
Example Response:
{ "message": "Dog breed found.", "status": "success", "id": 2, "breed": "dalmatian", "createdOn": "2019-01-21T13:37:51+11:00[Australia/Sydney]", "accessUrl": "https://s3.amazonaws.com/petdog-bucket/3ce2b612-5e39-4330-9e86-58947ceedc37.jpg" }
Api Endpoing signature :
http://[host]:[port]/petdogs/dogs/{id}
Supported HTTP method :Only DELETE
Example Response:
{ "message": "Delete request is successfully executed", "status": "success" }
Api Endpoing signature :
http://[host]:[port]/petdogs/dogs?breedName=[breed name]
Supported HTTP method :Only GET
Example Response:
{ "message": "Found dogs for the given breed name", "status": "success", "dogs": [ { "message": "Dog breed found.", "status": "success", "id": 3, "breed": "dalmatian", "createdOn": "2019-01-21T13:38:02+11:00[Australia/Sydney]", "accessUrl": "https://s3.amazonaws.com/petdog-bucket/375005ce-c593-4e81-93c0-5432507cf287.jpg" } ] }
Api Endpoing signature :
http://[host]:[port]/petdogs/dogs?size=[pagesize]&page=[pagenumber]
Supported HTTP method :Only GET
Note that page number starts with 0
Example Response:
{ "message": "Dog breed names found", "status": "success", "breeds": [ "keeshond", "dalmatian", "bullterrier-staffordshire", "elkhound-norwegian", "kuvasz", "hound-english" ] }