REST API written in Python Flask using SQLAlchemy as the ORM with auto migration capabilities
- Download & install Python 3.6
- Download & install Pipenv
python -m pip install -U pip
- Download & Install MySQL Server locally or use an external database (OPTIONAL)
- Download & install NodeJS
- Install nodemon (use sudo if you in linux)
npm i -g nodemon
# Clone the repository
https://mattareddy.syamala@innersource.accenture.com/scm/acpicp/managementServers-service.git
# Change into the directory
cd managementServers-service
# Install all required dependencies with
pipenv install --deploy --skip-lock
# Activate the project virtual environment
pipenv shell
# Create an local .env file and replace with the relevant values
cp .env.sample .env
You can also set the enviroment variables explicity (OPTIONAL)
PORT=9000
BUILD_DEV=development
DATABASE_URL=mysql+pymysql://user:pass@host:port/dbname
You can create the tables using the following set of commands
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
Start the app
python run.py
Start the app for developers
nodemon run.py
API Specifications
- GET: /managementServers/allManagementServers
- GET: /managementServers/{mgmtServerId}
- GET: /managementServers/activeMgmtServers
- POST: /managementServers
- PUT: /managementServers/{mgmtServerId}
- DELETE: /managementServers/{mgmtServerId}/{loggedInUser}
Example Get all managementServers curl http://localhost:{PORT}/managementServers Get some managementServers-perticular curl http://localhost:{PORT}/managementServers/1,2,3,4,
cd managementServers-api
# Build the docker image
docker build -t icp-managementServers .
# Run the docker container and put the port as specified in the .env file
docker run -d -p 7000:7000 --name icp-managementServers -e PORT=7000 -e BUILD_ENV='development' -e DATABASE_URL='mysql+pymysql://user:pass@host:port/dbname' -e DATABASE_test_URL='mysql+pymysql://user:pass@host:port/dbname1' icp-managementServers
# Check the logs
docker logs -f icp-managementServers
# Cleaup the container
docker stop icp-managementServers && docker rm icp-managementServers
python -m unittest -v src/tests/unit_mocktests.py
python -m unittest -v src/tests/integration_test.py
http://{ipaddress}:{PORT}/apidocs/
pylint /path/to/project --reports=y --ignored-classes=SQLAlchemy,scoped_session --disable=invalid-name,locally-disabled,arguments-differ,no-value-for-parameter,useless-object-inheritance,superfluous-parens,no-else-return,too-many-instance-attributes,no-self-argument,len-as-condition,singleton-comparison,attribute-defined-outside-init,cyclic-import,unused-variable,attribute-defined-outside-init,wrong-import-order,wrong-import-position
Mattareddy Syamala