J.E.A.S Flashcards

1
Q
Identifying a Resource
[collection]
[singleton sub-collection]
[singleton .. of others]
[singleton .. resources]
[tenant]
[application]
A

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}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A resource MUST be accessed from a collection.

A

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}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A singleton resource MAY contain sub-collection resources.

A

For example, sub-collection resource addresses of a particular customer can be identified using the URI /customers/{customerId}/addresses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A singleton resource SHOULD be accessed independently of other resources

A

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}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A singleton resource MAY contain other singleton resources.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A resource that is specific to a tenant MUST be identified with the URI format {tenant}/{id}

A

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}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Application Specific Resources

A

An application specific resource is either a Gateway, Backend-for-Frontend or a Vendor specific resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Characteristics of a Gateway resource

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Characteristics of a Backend-for-Frontend resource

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Characteristics of a Vendor specific resource

A
  • The schema of the resource is defined by the Vendor * It is built for a specific Vendor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Because an application specific resource is coupled to specific clients the resource …

A

the resource will change with that client’s requirements; it is NOT a stable platform to build any other applications on top of.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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?

A

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?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A server SHOULD implement the PATCH method to

A

allow clients to modify a resource without replacing it completely. Just Eat prefers PATCH of a resource over POST to an action, i.e. PATCH /resources/{resourceId} instead of POST /resources/{resourceId}/change-something

17
Q

You SHOULD think carefully before exposing the DELETE action publicly.

A

You MAY want to soft delete resources and return 410 GONE for requests attempting to access this resource. You can then, manually reinstate the resource or offer an “undo” API.

18
Q

GET HTTP requests SHOULD NOT

A

change state and they should be idempotent.

19
Q

You MAY use the … verb if a request to create or update a resource results in the resource being created or updated at the time of the request bring processed (i.e. before the response is returned)

A

PUT

20
Q

You MUST use the … verb if a request to create or update a resource results in the resource being created or updated after the request has been processed (i.e. after the response is returned)

A

POST

21
Q

You MUST NOT use the … verb if you cannot guarantee idempotence

A

PUT

22
Q

You MUST return equivalent representations of a resource for … and … requests to the same resource

A

GET, PUT

23
Q

The difference between PUT and PATCH.

A

The difference between the PUT and PATCH requests is reflected in the way the server processes the enclosed entity to modify the resource identified by the Request-URI. In a PUT request, the enclosed entity is considered to be a modified version of the resource stored on the origin server, and the client is requesting that the stored version be replaced. With PATCH, however, the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.

24
Q

Exemplify: Because the behaviour of PUT is to replace the entire resource it is difficult to evolve a resource that supports the PUT verb from the API side.

A

For example, the API cannot simply add a new property to the resource, as a client that was coded before the addition would be attempting a PUT that erased that property.

25
Q

As such, … is mainly suitable only for a situation where the resource is owned by the client and the service is simply acting as a data store. (Think of how a wiki gives ownership of the page to the client to make changes.)

A

PUT

26
Q

You MAY use the … verb if a request to create or update a resource results in the resource being created or updated at the time of the request bring processed (i.e. before the response is returned)

A

PUT/PATCH

27
Q

You MUST use the … verb if a request to create or update a resource results in the resource being created or updated after the request has been processed (i.e. after the response is returned)

A

POST

28
Q

You MUST return equivalent representations of a resource for … and … requests to the same resource

A

GET, PUT

29
Q

You MUST NOT use the … verb if you cannot guarantee idempotence. Instead implement … or ….

A

PUT, PATCH or POST.

30
Q

Can I guarantee idempotency in this example:

Given I have a Customer resource with the URI /customers/{id}
When I PUT a Customer to /customers/{id}
And the Customer is identical to the resource that exists at /customers/{id}
And I publish a CustomerChanged event
And other microservices can subscribe to to the CustomerChanged event

A

No

31
Q

Can I guarantee idempotency in this example:

Given I have a Customer resource with the URI /customers/{id}
When I PUT a Customer to /customers/{id}
And the Customer is identical to the resource that exists at /customers/{id}
And I do not publish a CustomerChanged event
And other microservices can subscribe to to the CustomerChanged event

A

Yes

32
Q

Can I guarantee idempotency in this example:

Given I have a Customer resource with the URI /customers/{id}
When I PUT a Customer to /customers/{id}
And the Customer is identical to the resource that exists at /customers/{id}
And I publish a CustomerChanged event
And the CustomerChanged event is internal to my microservice
And any external effects that are a result of the CustomerChanged event being published are all triggered idempotently

A

Yes