Context
To be fully compliant with the REST principles enumerate in Fielding's dissertation, a resource must contains links that redirect to other resources that have a relation with it functionally, like for a bank account that display dynamically a withdraw link, or semantically as it could be related to an other concept related to the resource.
More generally this concept of linking is presented has HATEOAS. L. Richardson described it very well as part of its Maturity Model (specifically the level 3)
Problem
From a technical point of view, links are not so easy to implement. I'm facing particularly a problem when modeling my resources in classes. I must associate several fields that corresponds to an URI. Here is an example of what it looks (based on this example), with a BankingAccount resource describing its characteristic :
class BankingAccount() {
Double totalAmount;
String ownerName;
URI uriToCloseAccount;
URI uriToWithdrawMoney;
}
Here, the field uriToCloseAccount
is a URI (=a link) that redirect to an other resource in order to close the account. In the same mind, an other URI uriToWithdrawMoney
will redirect to a resource that process the withdraw.
It could be possible for a client to retrieve this resource through GET (at URI /bankingAccount/[id]) but also update only its owner name, for whatever reason.
Problem
Is it realistic to suppose that a client could update the uriToCloseAccount
field of a BankingAccount's resource ?
I'm not completely fine with this. I always assumed in the past, that it's not a client that is responsible of managing URI. They are here just to indicate a path to follow (or the operations to do, depending on the hypermedia format chosen) by the server itself to the client.
So the underlying question is: does links are part of resource model ? Or it is an information that is outside of the model (i don't know, maybe in the format chosen ?)
Thanks in advance !