J.E.A.S Flashcards
Identifying a Resource [collection] [singleton sub-collection] [singleton .. of others] [singleton .. resources] [tenant] [application]
A resource MUST be accessed from a collection.
A singleton resource MAY contain sub-collection resources.
A singleton resource SHOULD be accessed independently of other resources
A singleton resource MAY contain other singleton resources.
A resource that is specific to a tenant MUST be identified with the URI format {tenant}/{id}
A resource that is designed to support a specific application experience, such as a Gateway, Backend-for-Frontend or vendor specific integration, MUST have their URI prefixed with /applications/{applications}.
A resource MUST be accessed from a collection.
For example, customers is a collection resource and customer is a singleton resource. The customers collection resource can be identified using the URI /customers. A single customer resource can be identified using the URI /customers/{customerId}.
A singleton resource MAY contain sub-collection resources.
For example, sub-collection resource addresses of a particular customer can be identified using the URI /customers/{customerId}/addresses.
A singleton resource SHOULD be accessed independently of other resources
For example, order is a resource that can belong to a particular customer. The order resource can belong to a particular restaurant. The order resource can accessed with the URI /order/{orderId}.
A singleton resource MAY contain other singleton resources.
For example, the name resource of a particular customer is dependant on the customer. There is no reasonable future scenario where it would be useful for a client to access a name independently of the customer. The name of a particular customer can be identified using the URI /customers/{customerId}/name
A resource that is specific to a tenant MUST be identified with the URI format {tenant}/{id}
For example, a restaurant resource can be identified with a restaurantId. There is the possibility of multiple tenants having the same restaurantId. A restaurantId is specific to a tenant, A restaurant resource can be identifier using the URI /restaurants/{tenant}/{restaurantId}.
A resource that is designed to support a specific application experience, such as a Gateway, Backend-for-Frontend or vendor specific integration, MUST have their URI prefixed with /applications/{applications}.
For example, a resource designed to support the efficient rendering of the menu page on the web, iOS and Android might have the URI /applications/menuorchestrator/menu. A resource designed to support a callback from Twilio for call centre IVR functionality might be /applications/twilio-ivr/callback.
Application Specific Resources
An application specific resource is either a Gateway, Backend-for-Frontend or a Vendor specific resource.
Characteristics of a Gateway resource
- It is built for a specific client or group of clients
- It is designed to reduce the number of TCP connections a client has to open to get resources in parallel by combining those resources at the gateway
Characteristics of a Backend-for-Frontend resource
- Same as Gateway resource
- It may contain some sort of orchestration of business logic specific to the clients
- It may choose to represent resources differently to how the underlying systems represent those resources
Characteristics of a Vendor specific resource
- The schema of the resource is defined by the Vendor * It is built for a specific Vendor
Because an application specific resource is coupled to specific clients the resource …
the resource will change with that client’s requirements; it is NOT a stable platform to build any other applications on top of.
Exemplifying the question: If resource is a sub-resource in one context, but can be accessed by itself in a separate context, then what URI should be used to access the resource?
For example: A restaurant with the URI /restaurant/{restaurantId} may have a products sub-resource with the URI /restaurant/{restaurantId}/products/{productId}. If the productId is a unique identifier, there are no other restaurants which have a product with the same product id, then it is also valid for the product to have the URI /products/{productId}. Which URI should be used to fetch the product?
If resource is a sub-resource in one context, but can be accessed by itself in a separate context, then what URI should be used to access the resource?
The preference is for resources that can be accessed independently of other resources to be accessed independently of other resources. This allows for the resource to be reused in other scenarios
Exemplifying: The preference is for resources that can be accessed independently of other resources to be accessed independently of other resources. This allows for the resource to be reused in other scenarios
A customer with the URI /customer/{customerId} may have an orders sub-resource with the URI /customer/{customerId}/orders/{orderId}. A restaurant with the URI /restaurant might also reference the same orders resource. Which this implementation there is no obvious solution for how the client should access the order resource, nor is there a obvious solution for how the server should provide a reference the order resource. The better solution is for the order to have the URI /order/{orderId} which both customer and restaurant can reference.