API Star tools to create CRUD resources.
Project description
- Version:
0.2.4
- Status:
Production/Stable
- Author:
José Antonio Perdiguero López
API Star tools to create CRUD resources.
Features
The resources are classes with a default implementation for methods:
create: Create a new element for this resource.
retrieve: Retrieve an element of this resource.
update: Update (partially or fully) an element of this resource.
delete: Delete an element of this resource.
list: List resource collection.
drop: Drop resource collection.
The routes for these methods are:
Method |
Verb |
URL |
---|---|---|
create |
POST |
/ |
retrieve |
GET |
/{element_id}/ |
update |
PUT |
/{element_id}/ |
delete |
DELETE |
/{element_id}/ |
list |
GET |
/ |
drop |
DELETE |
/ |
Quick start
Install API star CRUD:
pip install apistar-crud
Create a model for your resource:
# Example using SQL Alchemy
class PuppyModel(Base):
__tablename__ = "Puppy"
id = Column(Integer, primary_key=True)
name = Column(String)
Create an input type and output_type for your resource:
class PuppyInputType(types.Type):
name = validators.String()
class PuppyOutputType(types.Type):
id = validators.Integer()
name = validators.String()
Now create your resource:
from apistar_crud.sqlalchemy import Resource
class PuppyResource(metaclass=Resource):
model = PuppyModel
input_type = PuppyInputType
output_type = PuppyOutputType
methods = ("create", "retrieve", "update", "delete", "list", "drop")
The resource generates his own routes, so you can add it to your main routes list:
from apistar import Include
routes = [
Include("/puppy", "Puppy", PuppyResource.routes),
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for apistar_crud-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fee86ddba6204dd16ad088377cf31e94f69f47946075ba283bfb658f7d568aa |
|
MD5 | 6dd8eb8b873b214e659b25a7f37c4996 |
|
BLAKE2b-256 | c71edbd2df7894b69a00da60f87043a66d992e669233ba577b8eccdcd114d197 |