Exception specifications for Sandman
The model module is repsonsible exposes the sandman.model.Model class, from which user models should derive. It also makes the register() function available, which maps endpoints to their associated classes.
Register with the API a sandman.model.Model class and associated endpoint.
Parameters: | cls (sandman.model.Model or tuple) – User-defined class derived from sandman.model.Model to be registered with the endpoint returned by endpoint() |
---|
Activate each pre-registered model or generate the model classes and (possibly) register them for the admin.
Parameters: |
|
---|
The Model class is meant to be the base class for user Models. It represents a table in the database that should be modeled as a resource.
Bases: flask_admin.contrib.sqla.view.ModelView
Mixin admin view class that displays primary keys on the admin form
Mass-model action view.
Create model view
Delete model view. Only POST method is allowed.
Edit model view
List view
Bases: flask_admin.contrib.sqla.view.ModelView
Mass-model action view.
Create model view
Delete model view. Only POST method is allowed.
Edit model view
List view
Bases: object
A mixin class containing the majority of the RESTful API functionality.
sandman.model.Model is the base class of :class:`sandman.Model, from which user models are derived.
override __endpoint__ if you wish to configure the sandman.model.Model‘s endpoint.
Default: __tablename__ in lowercase and pluralized
override __methods__ if you wish to change the HTTP methods this sandman.model.Model supports.
Default: ('GET', 'POST', 'PATCH', 'DELETE', 'PUT')
Will be populated by SQLAlchemy with the table’s meta-information.
The name of the database table this class should be mapped to
Default: None
Return a dictionary containing only the attributes which map to an instance’s database columns.
Return type: | dict |
---|
Set a set of attributes which correspond to the sandman.model.Model‘s columns.
Parameters: | dictionary (dict) – A dictionary of attributes to set on the instance whose keys are the column names of the sandman.model.Model‘s underlying database table. |
---|
Set all attributes which correspond to the sandman.model.Model‘s columns to the values in dictionary, inserting None if an attribute’s value is not specified.
Parameters: | dictionary (dict) – A dictionary of attributes to set on the instance whose keys are the column names of the sandman.model.Model‘s underlying database table. |
---|
Sandman REST API creator for Flask and SQLAlchemy
Return a response for the resource of the appropriate content type.
Parameters: | resource (sandman.model.Model) – resource to be returned in request |
---|---|
Return type: | flask.Response |
Return a response for the resources of the appropriate content type.
Parameters: | resources – resources to be returned in request |
---|---|
Return type: | flask.Response |
Return the appropriate Response for deleting an existing resource in collection.
Parameters: |
|
---|---|
Return type: | flask.Response |
Return the sandman.model.Model associated with the endpoint collection.
Parameters: | collection (string) – a sandman.model.Model endpoint |
---|---|
Return type: | sandman.model.Model |
Return the appropriate Response for retrieving a collection of resources.
Parameters: |
|
---|---|
Return type: | flask.Response |
Return the appropriate Response for retrieving a single resource.
Parameters: |
|
---|---|
Return type: | flask.Response |
Return the appropriate Response for retrieving an attribute of a single resource.
Parameters: |
|
---|---|
Return type: | flask.Response |
Return the data from the incoming request based on the Content-type.
Return a response with the appropriate status code, message, and content type when an InvalidAPIUsage exception is raised.
Return information about each type of resource and how it can be accessed.
Return the appropriate Response with status code 204, signaling a completed action which does not require data in the response body
Return type: | flask.Response |
---|
“Upsert” a resource identified by the given key and return the appropriate Response.
If no resource currently exists at /<collection>/<key>, create it with key as its primary key and return a resource_created_response().
If a resource does exist at /<collection>/<key>, update it with the data sent in the request and return a no_content_response().
Note: HTTP PATCH (and, thus, patch_resource()) is idempotent
Parameters: |
|
---|---|
Return type: | flask.Response |
Return the appropriate Response based on adding a new resource to collection.
Parameters: | collection (string) – a sandman.model.Model endpoint |
---|---|
Return type: | flask.Response |
Replace the resource identified by the given key and return the appropriate response.
Parameters: | collection (string) – a sandman.model.Model endpoint |
---|---|
Return type: | flask.Response |
Return HTTP response with status code 201, signaling a created resource
Parameters: | resource (sandman.model.Model) – resource created as a result of current request |
---|---|
Return type: | flask.Response |
Return a response for the resource of the appropriate content type.
Parameters: | resource (sandman.model.Model) – resource to be returned in request |
---|---|
Return type: | flask.Response |
Return the resources in collection, possibly filtered by a series of values to use in a ‘where’ clause search.
Parameters: |
|
---|---|
Return type: | class:sandman.model.Model |