A singleton sub-resource is a hybrid of a resource and a property: it stores data inherent to a parent resource in a separate, independently addressable location. Use it when the data is large, complex, highly restricted, or changes at a different rate. section 12.0 section 12.2
Apply the standard methods with these constraints:
- Get and update the singleton like a separate resource; address it with its own identifier, such as drivers/1/location. section 12.3.1
- Create it automatically when the parent is created; require no separate initialization method. section 12.3.1
- Delete it automatically with the parent; do not expose ordinary create or delete operations for the singleton. section 12.3.1 section 12.6
- Allow only one instance and consider a custom reset operation for restoring default attributes. section 12.4.2 section 12.6
Driver location
A Driver resource can keep slowly changing metadata such as a license plate while exposing frequently changing location data as a singleton sub-resource. Clients retrieve or partially update it through the location endpoint, while creating the driver creates the location automatically. section 12.1.1 section 12.3.1
Visualizes moving a location property from a resource into a Location singleton sub-resource. section 12.2
