GithubHelp home page GithubHelp logo

nicolyn2517 / customers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from csci-ga-2820-su23-001/customers

0.0 0.0 0.0 214 KB

NYU DevOps Customers Service Summer 2023

License: Apache License 2.0

Shell 1.48% Python 73.60% Makefile 3.66% Dockerfile 1.36% Procfile 0.07% Gherkin 4.68% HTML 5.79% JavaScript 9.36%

customers's Introduction

NYU DevOps Project Template

License Python

codecov Build Status Build Status

This is a skeleton you can use to start your projects

Overview

This project template contains starter code for your class project. The /service folder contains your models.py file for your model and a routes.py file for your service. The /tests folder has test case starter code for testing the model and the service separately. All you need to do is add your functionality. You can use the lab-flask-tdd for code examples to copy from.

Automatic Setup

The best way to use this repo is to start your own repo using it as a git template. To do this just press the green Use this template button in GitHub and this will become the source for your repository.

Manual Setup

You can also clone this repository and then copy and paste the starter code into your project repo folder on your local computer. Be careful not to copy over your own README.md file so be selective in what you copy.

There are 4 hidden files that you will need to copy manually if you use the Mac Finder or Windows Explorer to copy files from this folder into your repo folder.

These should be copied using a bash shell as follows:

    cp .gitignore  ../<your_repo_folder>/
    cp .flaskenv ../<your_repo_folder>/
    cp .gitattributes ../<your_repo_folder>/

Running the service

The project uses honcho which gets it's commands from the Procfile. To start the service:

$ honcho start

You could reach the service at: http://localhost:8000 as defined in the .flaskenv file, which Flask uses to load it's configuration from the environment by default.

Customer Service APIs

Customer Operations

Endpoint Methods Rule
create_customers POST /customers
get_customers GET /customers/{int:customer_id}
update_customers PUT /customers/{int:customer_id}
delete_a_customer DELETE /customers/{int:customer_id}
list_customers GET /customers

APIs Usage

Create a Customer

URL : http://127.0.0.1:8000/customers

Method : POST

Auth required : No

Permissions required : No

Create a customer using a JSON file that includes the customers's name, address, email, phone_number and password.

Example:

Request Body (JSON)

{
  "name": "John Doe",
  "address": "5th Fifth Ave, NY",
  "email": "[email protected]",
  "phone_number": "12345678",
  "password": "password",
  "available": True
}


Success Response : HTTP_200_CREATED

[
  {
    "id":1,
    "name": "John Doe",
    "address": "5th Fifth Ave, NY",
    "email": "[email protected]",
    "phone_number": "12345678",
    "password": "password",
    "available": True
}
]

Read a Customer

URL : http://127.0.0.1:8000/customers/{int:customer_id}

Method : GET

Auth required : No

Permissions required : No

Read all information of a customer with given id

Example:

Success Response : HTTP_200_OK

[
  {
    "id":1,
    "name": "John Doe",
    "address": "5th Fifth Ave, NY",
    "email": "[email protected]",
    "phone_number": "12345678",
    "password": "password",
    "available": True
}
]

Failure Response : HTTP_404_NOT_FOUND

{
  "error": "Not Found",
  "message": "404 Not Found: Customer with id '3' was not found.",
  "status": 404
}

Update a Customer

URL : http://127.0.0.1:8000/customers/{int:customer_id}

Method : PUT

Auth required : No

Permissions required : No

Updates a customer with id provided in the URL according to the updated fields provided in the body

Example:

Request Body (JSON)

  {
    "name": "John Foo",
    "address": "5th Fifth Ave, NY",
    "email": "[email protected]",
    "phone_number": "12345678",
    "password": "password",
    "available": True
}

Success Response : HTTP_200_OK

[
  {
    "id":1,
    "name": "John Foo",
    "address": "5th Fifth Ave, NY",
    "email": "[email protected]",
    "phone_number": "12345678",
    "password": "password",
    "available": True
}
]

Failure Response : HTTP_404_NOT_FOUND

{
  "error": "Not Found",
  "message": "404 Not Found: Customer with id '2' was not found.",
  "status": 404
}

Delete a Customer

URL : http://127.0.0.1:8000/customers/{int:customer_id}

Method : DELETE

Auth required : No

Permissions required : No

Deletes a Customer with id

Example:

Success Response : 204 NO CONTENT

List Customers

This is the planned version of listing customers. Currently the listing part still have some errors

URL : http://127.0.0.1:8000/customers

Method: GET

Auth required : No

Permissions required : No

List All Customers

Example:

Success Response : HTTP_200_OK

[
  {
    "id":1,
    "name": "John Foo",
    "address": "5th Fifth Ave, NY",
    "email": "[email protected]",
    "phone_number": "12345678",
    "password": "password",
    "available": True
}
]

Contents

The project contains the following:

.gitignore          - this will ignore vagrant and other metadata files
.flaskenv           - Environment variables to configure Flask
.gitattributes      - File to gix Windows CRLF issues
.devcontainers/     - Folder with support for VSCode Remote Containers
dot-env-example     - copy to .env to use environment variables
requirements.txt    - list if Python libraries required by your code
config.py           - configuration parameters

service/                   - service python package
├── __init__.py            - package initializer
├── models.py              - module with business models
├── routes.py              - module with service routes
└── common                 - common code package
    ├── error_handlers.py  - HTTP error handling code
    ├── log_handlers.py    - logging setup code
    └── status.py          - HTTP status constants
└── static                 - static code package
    ├── css                - UI page format
    ├── images             - UI page mage
    ├── js                 - UI page constants
    └── index.html         - UI page alignment

tests/              - test cases package
├── __init__.py     - package initializer
├── test_models.py  - test suite for business models
└── test_routes.py  - test suite for service routes

License

Copyright (c) John Rofrano. All rights reserved.

Licensed under the Apache License. See LICENSE

This repository is part of the NYU masters class: CSCI-GA.2820-001 DevOps and Agile Methodologies created and taught by John Rofrano, Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science, and NYU Stern School of Business.

customers's People

Contributors

iamalicialin avatar yanchenn avatar nikhilyadavnyu avatar jeffrey2545 avatar nicolyn2517 avatar jjrofrano avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.