Skip to content

Latest commit

 

History

History
151 lines (126 loc) · 2.56 KB

README.md

File metadata and controls

151 lines (126 loc) · 2.56 KB

Test REST API Implementation

This project demonstrates a REST API for managing "teams" and "people in those teams" using Django Rest Framework. The API allows performing CRUD (Create, Read, Update, Delete) operations for "team" and "person" objects.

Installation

  1. Clone the repository:

    git clone https://github.com/YuliaHladyshkevych/TeamManager.git
    cd TeamManager
  2. Create and activate a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # for Windows: venv\Scripts\activate
  3. Install required packages:

    pip install -r requirements.txt
  4. Apply migrations:

    python manage.py migrate
  5. Populate the database with initial data (optional):

    python manage.py populate_data
  6. Run the development server:

    python manage.py runserver

Using the API

Teams

  • Get a list of teams:

    GET /teams/
  • Create a new team:

    POST /teams/

    Request body:

    {
      "name": "Team Name",
      "description": "Team Description"
    }
  • Get a team by ID:

    GET /teams/{id}/
  • Update a team by ID:

    PUT /teams/{id}/

    Request body:

    {
      "name": "Updated Team Name",
      "description": "Updated Team Description"
    }
  • Delete a team by ID:

    DELETE /teams/{id}/
  • Get members of a team:

    GET /teams/{id}/members/
  • Add a member to a team:

    POST /teams/{id}/add_member/

    Request body:

    {
      "person_id": 1
    }
  • Filter members by first_name or/and last_name:

    GET /teams/{id}/filter_members/?first_name={first_name}&last_name={last_name}

People

  • Get a list of people:

    GET /people/
  • Create a new person:

    POST /people/

    Request body:

    {
      "first_name": "First Name",
      "last_name": "Last Name",
      "email": "[email protected]",
      "team": 1
    }
  • Get a person by ID:

    GET /people/{id}/
  • Update a person by ID:

    PUT /people/{id}/

    Request body:

    {
      "first_name": "Updated First Name",
      "last_name": "Updated Last Name",
      "email": "[email protected]",
      "team": 2
    }
  • Delete a person by ID:

    DELETE /people/{id}/
  • Filter persons by first_name or/and last_name:

    GET /people/filter_persons/?first_name={first_name}&last_name={last_name}