Services Entity provides resources for Services module for all entities that are defined with Entity API. If you are defining your own custom entities, or if you are using a contrib module that defines custom entities, you do not need to create Services resources for them: Services Entity takes care of this for you.

Each entity type is defined as a new resource, with the usual services: create, retrieve, update, delete, and index.

Requirements

  • Services
  • Entity API
  • Entity types must declare an access callback. See entity_crud_hook_entity_info() in Entity API's hook documentation, and also entity_access() for details.

Entity Processors

Services Entity comes with two entity processors. These determine the way in
which the provided resources handle parameters:

* The Generic Entity Processor returns and expects an entity structure exactly as Drupal uses internally.
* The Clean Entity Processor uses a simplified version of the entity structure,
with 'Drupalisms' such as deep field arrays removed. It also uses Entity API
metadata property names instead of entity schema property names.

Resources

An entity type 'foo' has a resource 'entity_foo' defined for it. On this the following services are defined:

- create:
- Send the object data in the body.
- Returns newly created entity.

- update:
- Send the object data in the body.
- Returns 200 if successful.

- retrieve
Has the following query string parameters:
- 'fields': specify which fields to return. For example: endpoint/entity_node/1?fields=title,nid

- delete
- Returns 200 if successful.

- index
Has the following query string parameters:
- 'fields': A comma separated list of fields to get.
- 'parameters': Filter parameters array of entity properties, such as parameters[title]="test"
- 'page': The zero-based index of the page to get, defaults to 0.
- 'pagesize': Number of records to get per page. This has a maximum imposed on it to prevent excessive load to the server. By default this is 100, but this may be changed in the admin settings.
- 'sort': Field or property to sort by.
- 'direction': Direction of the sort. ASC or DESC.