sandman Package¶
sandman
Package¶
Sandman automatically generates a REST API from your existing database, without you needing to tediously define the tables in typical ORM style. Simply create a class for each table you want to expose in the API, give it’s associated database table, and off you go! The generated API essentially exposes a completely new system based on your existing data, using HATEOAS.
exception
Module¶
Exception specifications for Sandman
model
Module¶
The model module is repsonsible exposes the Model class, from whic user models should derive. It also makes the ‘register’ function available, which maps endpoints to their associated classes.
-
class
sandman.model.
DatabaseColumnDictMixin
¶ Bases:
object
Set an instances database-relevant attributes from a dict or return a dict containing only database-column attributes of the instance.
-
as_dict
()¶ Return a dictionary of each of the instance’s database columns and their associted values.
-
from_dict
(dictionary)¶ Set the instance’s attributes based on a dictionary of instance’s database columns.
-
-
class
sandman.model.
Resource
¶ Bases:
sandman.model.DatabaseColumnDictMixin
A RESTful resource
-
classmethod
endpoint
()¶
-
links
()¶ Return a list of links for endpoints related to the resource.
-
primary_key
()¶
-
resource_uri
()¶ Return the URI at which the resource can be found.
-
classmethod
-
sandman.model.
register
(cls)¶ Register an endpoint with the Model class that represents it
sandman
Module¶
Sandman REST API creator for Flask and SQLAlchemy
-
sandman.sandman.
add_resource
(collection)¶ Return response for adding a resource
-
sandman.sandman.
collection_handler
(collection)¶ Handler for a collection of resources
-
sandman.sandman.
created_response
(resource)¶ Return response for created resource
-
sandman.sandman.
delete_resource
(collection, lookup_id)¶ Return response for deleting a resource
-
sandman.sandman.
get_session
()¶ Return a database session
-
sandman.sandman.
no_content_response
()¶ Return response when no resource is returned in body
-
sandman.sandman.
patch_resource
(collection, lookup_id)¶ Return response for patching a resource
-
sandman.sandman.
resource_handler
(collection, lookup_id)¶ Handler for single resource
-
sandman.sandman.
unsupported_method_response
()¶ Return response when no resource is returned in body
-
sandman.sandman.
validate
(cls, method, resource=None)¶