tags:

views:

15

answers:

1

Hi All,

I am just looking for some opinions on what is the best RESTful way of updating multiple different Resource types or if I am looking at the problem in the wrong way.

We are looking for a solution change the attribute of a collection of different resource types.

For example, we have an account and deals, each of which have a owner and deals are linked to an account. The owner of the account may also own some or all of the deals associated with the account but deals can have owners that are not the account owner. We are looking to implement functionality that will allow us to replace the owner of an account and also update the deals owner by the account owner in one call.

What would be the best way to implement such functionality using REST?

Many Thanks

+1  A: 

You could create a new virtual resource that is responsible for making the changes to the other resources.

Resources: User, Account, Deal

Account has an attribute, owner (a User)

Account has many Deals

Deal has an attribute, owner (a User)

User has many Deals

Want the resource to manage:

  • Changing Account owner
  • Changing Deal owner for all Deals associated with the Account where Deal owner == (old) Account owner

Synchronous:

URL /account_ownership_update

  • POST: Send the Account to be updated and the new User. Return success/failure

Asynchronous:

URL /account_ownership_update

  • POST: Send the Account to be updated and the new User. Return enqueue successful/failed
  • GET: Return the status of the update (pending, running, successful, failed)
fd
Thanks for that fd!That is something we had discussed here but we are very new to REST. It's good to get some feedback that this is a viable option. Thanks again for info.
Stefg