Skip to content

hawk-sf/active_directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A simple Flask REST API to store, fetch, and update user/group records. Based off of specifications in code_test. Uses SQLite as its datastore. Written/tested with python 2.7.

Installation

After cloning the repository into a virtualenv, change into the project's root directory and install the requirements with:

pip install -r requirements.txt

The database can be initialized in the project's root, and an initial migration run, using:

python manage.py deploy

You're all set.

Testing and Running the Dev Server

To verify your installation, the unit tests can be run using:

python manage.py test

The local web server can be run, on http://localhost:5000, using:

python manage.py runserver

API Overview

Note: in this implemenation, a user only requires the userid field, and a group the name field.

GET /users/<userid>

Returns JSON object. Succesful responses will return user representation inside the result attribute. Non 200 responses will contain an error attribute.

POST /users

Expects user information, with the following fields:

{
    "first_name": "Joe",
    "last_name": "Smith",
    "userid": "jsmith",
    "groups": ["admins", "users"]
}

Accepts either a JSON payload, in the format above, or standard form data. userid is required. Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute.

PUT /users/<userid>

Expects user information, with the following fields:

{
    "first_name": "Joe",
    "last_name": "Smith",
    "groups": ["admins", "users"]
}

Accepts either a JSON payload, in the format above, or standard form data. Replaces current user info with new data. Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute. Will return 404 if user doesn't already exist.

DELETE /users/<userid>

Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute. Will return 404 if user doesn't already exist.

GET /groups/<group name>

Returns JSON object. Succesful responses will return a list of userid's inside the result attribute. Non 200 responses will contain an error attribute.

POST /groups

Expects group information, with the following fields:

{
    "name": "admins"
}

Accepts either a JSON payload, in the format above, or standard form data. name is required. Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute.

PUT /groups/<group name>

Expects a list of userids:

{
    "userids": ["jsmith"]
}

Accepts either a JSON payload, in the format above, or standard form data. userids is required. Replaces current users with the new list. Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute. Will return 404 if group doesn't already exist.

DELETE /groups/<group name>

Succesful responses will return {"result": true}. Non 200 responses will contain an error attribute. Will return 404 if group doesn't already exist.

About

Simple Flask REST API example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published