Skip to content

This repository contains the code for the NYU Devops FALL 20 inventory team

License

Notifications You must be signed in to change notification settings

devops-fall-20-inventory/inventories

Repository files navigation

Inventory

Build Status codecov

License PyPI pyversions

GitHub issues GitHub closed issues

GitHub commits GitHub last commit

Description

This repository contains all the work of the Inventory Squad as part of the Fall '20 DevOps under John Rofrano.

The inventory resource keeps track of how many of each product we have in our warehouse. At a minimum it will reference a product and the quantity on hand. Inventory also tracks restock levels and the condition of the item (i.e., new, open box, used). Restock levels will help you know when to order more products. Being able to query products by their condition (e.g., new, used) is very useful.

Squad

  1. Arahant Ashok Kumar - Product Owner
  2. Arun Muthu
  3. Hardik Rokad
  4. Jiazhou Liu - Agile Coach
  5. Kainat Naeem

Getting Started

Database Schema

Column Data type Condition
product_id <integer> product_id > 0
condition <string> <new/used/open box>
quantity <integer> quantity > 0
restock_level <integer> restock_level > 0
available <integer> available == 0/1

API endpoints

URL-Dev: https://nyu-inventory-service-f20-dev.us-south.cf.appdomain.cloud

URL-Prod: https://nyu-inventory-service-f20.us-south.cf.appdomain.cloud

URL- Pipeline: https://cloud.ibm.com/devops/pipelines/e3ae5a6c-6089-44d2-ae38-5425acb197bb?env_id=ibm:yp:us-south

Method URI Description Content-Type Sample Payload
POST /api/inventory Given the data body this creates an inventory record in the DB application/json {"product_id": 321,"condition": "new","available": 1,"quantity": 2,"restock_level": 1}
GET /api/inventory Returns a collection of all inventories in the DB N/A N/A
GET /api/inventory/<int:product_id>/condition/<string:condition> Returns the inventory record with the given product_id and condition N/A N/A
PUT /api/inventory/<int:product_id>/condition/<string:condition> Updates the inventory record with the given product_id and condition application/json {"available": 1,"quantity": 2,"restock_level": 1}
PUT /api/inventory/<int:product_id>/condition/<string:condition>/activate Given the product_id and condition this updates available = 1 N/A N/A
PUT /api/inventory/<int:product_id>/condition/<string:condition>/deactivate Given the product_id and condition this updates available = 0 N/A N/A
PUT /api/inventory/<int:product_id>/condition/<string:condition>/restock Given the product_id, condition and amount (body) this updates quantity += amount application/json {"amount": 2}
DELETE /api/inventory/<int:product_id>/condition/<string:condition> Given the product_id and condition this updates available = 0 N/A N/A

Testing and Running locally

To run and test the code, you can use the following command:

git clone https://github.com/devops-fall-20-inventory/inventories.git
cd inventories
vagrant up
vagrant ssh
cd /vagrant
nosetests
pylint service
FLASK_APP=service:app flask run -h 0.0.0.0
  1. You can type nosetests under /vagrant to check different test cases and the overall coverage. The coverage is displated by default.
  2. PyLint should return a score more than 9.
  3. Then you can test the APIs in the browser from you host machine, or on Postman (recommended).