The surf.rest Module¶
-
class
surf.rest.Rest(resources_namespace, concept_class)[source]¶ Bases:
objectThe
Restclass handles the generation of REST like methods to perform CRUD operations on asurf.resource.Resourceinstancenote: The REST api exposed is designed in accordance with the REST controller used in pylons applications, it adheres to the REST specification and offers extra features
Parameters: - resources_namespace (
rdflib.namespace.Namespaceor str) – the uri used by instances - concept_class (
surf.resource.Resource) – the class for which the REST interface is exposed
-
create(json_params)[source]¶ REST : POST /: Create a new item, creates a new
surf.resource.ResourceinstanceParameters: json_params (dict) – extra JSON parameters to set as instance attributes
-
delete(id)[source]¶ REST : DELETE /id: Delete an existing item. removes an instance from the underlying
surf.store.StorestoreParameters: id (str) – the resources id
-
edit(id, json_params)[source]¶ REST : GET /id;edit: alias for
surf.rest.Rest.update()methodParameters: - id (str) – the resources id
- json_params (dict) – extra JSON parameters to set as instance attributes
-
index()[source]¶ REST : GET /: All items in the collection,
Returns: all instances for the current surf.resources.ResourceReturn type: list or surf.resources.ResultProxy
-
new(json_params)[source]¶ REST : GET /new: Form to create a new item. alias for
surf.rest.Rest.create()methodParameters: json_params (dict) – extra JSON parameters to set as instance attributes
-
classmethod
resource(session, resources_namespace, concept_class, id)[source]¶ convenience method to get a resource given the arguments
Parameters: - session (
surf.session.Session) – the SuRF session - resources_namespace (
rdflib.namespace.Namespaceor str) – the uri used by instances - concept_class (
surf.resource.Resource) – the class for which the REST interface is exposed - id (str) – the resources id
Returns: the resource
Return type: surf.resources.Resource- session (
- resources_namespace (