Loading ...
Sorry, an error occurred while loading the content.
 

RESTful URLs for non-CRUD operations

Expand Messages
  • Keyur Shah
    I understand that it s always important to model everything as a resource in a REST system and perform CRUD operations on them (so that GET, POST, PUT and
    Message 1 of 9 , Apr 19, 2007
      I understand that it's always important to model everything as a
      resource in a REST system and perform CRUD operations on them (so that
      GET, POST, PUT and DELETE can fit the bill). But there might be cases
      where you have to model non-CRUD operations in your REST system - and
      not all reasons are technical. You customers are used to a certain
      vocabulary which contains well-known and well-accepted verbs and you
      simply can't change them to fit the "resource" paradigm.

      So given this constraint that you absolutely must have non-standard
      verbs, what's the best way to model them?

      I have a blog entry on this and would appreciate your suggestions.

      http://abstractfinal.blogspot.com/2007/04/restful-urls-for-non-crud-operations.html

      Thanks,
      Keyur
    • Jon Hanna
      ... Eh, you re 3 different approaches are all the same? You re still GETting representations of resources, but using different URIs for the resources. POST
      Message 2 of 9 , Apr 19, 2007
        Keyur Shah wrote:
        > So given this constraint that you absolutely must have non-standard
        > verbs, what's the best way to model them?
        >
        > I have a blog entry on this and would appreciate your suggestions.
        >
        > http://abstractfinal.blogspot.com/2007/04/restful-urls-for-non-crud-operations.html

        Eh, you're 3 different approaches are all the same? You're still GETting
        representations of resources, but using different URIs for the resources.

        POST allows you to do CRUDE rather than CRUD. Do that.
      • Bob Haugen
        ... Stefan Tilkov dealt somewhat with the CRUD issue in his blog comment, so I ll come at this from a different angle: What vocabulary do you really have in
        Message 3 of 9 , Apr 19, 2007
          On 4/19/07, Keyur Shah <keyurva@...> wrote:
          > I understand that it's always important to model everything as a
          > resource in a REST system and perform CRUD operations on them (so that
          > GET, POST, PUT and DELETE can fit the bill). But there might be cases
          > where you have to model non-CRUD operations in your REST system - and
          > not all reasons are technical. You customers are used to a certain
          > vocabulary which contains well-known and well-accepted verbs and you
          > simply can't change them to fit the "resource" paradigm.
          >
          > So given this constraint that you absolutely must have non-standard
          > verbs, what's the best way to model them?

          Stefan Tilkov dealt somewhat with the CRUD issue in his blog comment,
          so I'll come at this from a different angle:

          What vocabulary do you really have in mind? You mentioned "walk" and
          "talk" in your blog entry, but I got the impression that those were
          made-up examples. Any discussion might be more more useful if we
          considered the real problem.
        • Benoit Fleury
          Hi, I m interested in the REST architectural style for a few time so I hope to not say too much wrong things. (I talk about your blog post) I think your 3
          Message 4 of 9 , Apr 19, 2007
            Hi,

            I'm interested in the REST architectural style for a few time so I hope
            to not say too much wrong things.

            (I talk about your blog post)

            I think your 3 propositions are actually the same. It's 3 ways to put
            the action in the URI. The mistake is here.

            There may be different solution to your problem. You say that in the
            REST architectural style "everything is a resource", you're right so we
            mustn't, i think, make a 1-to-1 relationship between our object model
            (for example :)) and the REST data model. I think that the mapping may
            be complex and don't have find yet interesting example of mapping
            between OO models and REST models. But maybe you have to find if there
            exists other resources on your source model which are not easy to
            translate to a REST resource.

            A second solution is to only use the Person resource. If we suppose we
            have to deal with a person resource and only that and we want that this
            person walk from 1 unit towards the north, we have to assume that the
            Person resource knows its position. The client has to know the current
            position of the Person. And to move the Person I think the client should
            POST to the server the intended state of the resource (the new position)

            Note: I didn't answer to your question. I just refuse the axiom " So
            given this constraint that you absolutely must have non-standard verbs".

            Hope it helps.

            -- benoit

            Keyur Shah a écrit :
            >
            > I understand that it's always important to model everything as a
            > resource in a REST system and perform CRUD operations on them (so that
            > GET, POST, PUT and DELETE can fit the bill). But there might be cases
            > where you have to model non-CRUD operations in your REST system - and
            > not all reasons are technical. You customers are used to a certain
            > vocabulary which contains well-known and well-accepted verbs and you
            > simply can't change them to fit the "resource" paradigm.
            >
            > So given this constraint that you absolutely must have non-standard
            > verbs, what's the best way to model them?
            >
            > I have a blog entry on this and would appreciate your suggestions.
            >
            > http://abstractfinal.blogspot.com/2007/04/restful-urls-for-non-crud-operations.html
            > <http://abstractfinal.blogspot.com/2007/04/restful-urls-for-non-crud-operations.html>
            >
            > Thanks,
            > Keyur
            >
            >
          • Bill de hOra
            ... Some examples: - any Plone URLs ending in /edit or /view - Atom protocol edit URIs. - MoinMoin ?action= URLs - Zimbra export URLs (URL per format) -
            Message 5 of 9 , Apr 19, 2007
              Bob Haugen wrote:
              >
              >
              > On 4/19/07, Keyur Shah <keyurva@... <mailto:keyurva%40yahoo.com>>
              > wrote:
              > > I understand that it's always important to model everything as a
              > > resource in a REST system and perform CRUD operations on them (so that
              > > GET, POST, PUT and DELETE can fit the bill). But there might be cases
              > > where you have to model non-CRUD operations in your REST system - and
              > > not all reasons are technical. You customers are used to a certain
              > > vocabulary which contains well-known and well-accepted verbs and you
              > > simply can't change them to fit the "resource" paradigm.
              > >
              > > So given this constraint that you absolutely must have non-standard
              > > verbs, what's the best way to model them?
              >
              > Stefan Tilkov dealt somewhat with the CRUD issue in his blog comment,
              > so I'll come at this from a different angle:
              >
              > What vocabulary do you really have in mind? You mentioned "walk" and
              > "talk" in your blog entry, but I got the impression that those were
              > made-up examples. Any discussion might be more more useful if we
              > considered the real problem.

              Some examples:

              - any Plone URLs ending in /edit or /view

              - Atom protocol "edit" URIs.

              - MoinMoin ?action= URLs

              - Zimbra export URLs (URL per format)

              - citizensinformation.ie /entry.xml URLs (Atom URLs)

              Fwiw, I don't buy this:

              "You customers are used to a certain vocabulary which contains
              well-known and well-accepted verbs"

              it's usually the framework designers that are making you do this not
              customers (eg most Java frameworks are action/controller based). Take
              the frameworks away, and then it's DSL and Domain Model aficionados
              designing things in a certain way. Not customers.

              cheers
              Bill
            • Bill de hOra
              ... How are non-CRUD operations modeled in an RDBMS system? cheers Bill
              Message 6 of 9 , Apr 19, 2007
                Bill de hOra wrote:
                >
                >
                > Bob Haugen wrote:
                > >
                > >
                > > On 4/19/07, Keyur Shah <keyurva@...
                > <mailto:keyurva%40yahoo.com> <mailto:keyurva%40yahoo.com>>
                > > wrote:
                > > > I understand that it's always important to model everything as a
                > > > resource in a REST system and perform CRUD operations on them (so that
                > > > GET, POST, PUT and DELETE can fit the bill). But there might be cases
                > > > where you have to model non-CRUD operations in your REST system

                How are non-CRUD operations modeled in an RDBMS system?

                cheers
                Bill
              • Keyur Shah
                ... If whatever.com/maps created another set of resources where /directions was replaced by /findRoute and /location was replaced by /queryAddress and
                Message 7 of 9 , Apr 19, 2007
                  Bob Haugen <bob.haugen@...> wrote:
                  On 4/19/07, Keyur Shah wrote:
                  > So say I am google maps... I need to design a rest system that can
                  > perform 2 operations - find route and query an address... The REST way
                  > would probably be:
                  >
                  > http://google.com/maps/directions?from=foo&to=bar
                  > http://google.com/maps/location?address=blah
                  >
                  > However, if google maps had legacy APIs / SOAP web services such that
                  > the verbs findRoute and queryAddress were firmly instilled in the
                  > verbiage of their user community, it might be a difficult proposition
                  > for them to suddenly introduce a new vocabulary for the same set of
                  > operations to their users. The user community sees them as operations
                  > and not in terms of the resulting resources (directions and
                  location).
                  > Legacy wins over technical correctness.

                  If whatever.com/maps created another set of resources
                  where /directions was replaced by /findRoute
                  and /location was replaced by /queryAddress
                  and everything else worked the same,
                  it's not a technical difference, just a naming difference.

                  Still just GETs with query args, but now with unstylish URIs.


                  Ahhh...imagining that irresistible "new car" smell?
                  Check out new cars at Yahoo! Autos.
                • Bill de hOra
                  ... I should say then that I buy the idea that URLs with domain specific verbs in them are rampant, and can t be conveniently ignored. cheers Bill
                  Message 8 of 9 , Apr 19, 2007
                    Bill de hOra wrote:
                    >
                    >
                    > > On 4/19/07, Keyur Shah <keyurva@...
                    > <mailto:keyurva%40yahoo.com> <mailto:keyurva%40yahoo.com>>
                    > Fwiw, I don't buy this:
                    >
                    > "You customers are used to a certain vocabulary which contains
                    > well-known and well-accepted verbs"
                    >
                    > it's usually the framework designers that are making you do this not
                    > customers (eg most Java frameworks are action/controller based). Take
                    > the frameworks away, and then it's DSL and Domain Model aficionados
                    > designing things in a certain way. Not customers.

                    I should say then that I buy the idea that URLs with "domain specific"
                    verbs in them are rampant, and can't be conveniently ignored.

                    cheers
                    Bill
                  • Walden Mathews
                    Keyur, What you need to do is think of your custom verbs in terms of state transfer. When person/1 walks, what changes state? What is the pre-state and
                    Message 9 of 9 , Apr 20, 2007
                      Keyur,
                       
                      What you need to do is think of your "custom" verbs in terms of
                      state transfer.  When person/1 walks, what changes state?  What is
                      the pre-state and what is the post-state?  Can you define the state
                      change as an idempotent operation (move person/1 to coordinates
                      (x,y))?  Or is it non-idempotent (move person n units north, e units
                      east)?  Use your standard verbs against the resources which suffer
                      the change.  Make sure you know what those resources are and
                      that they are identified.  Voila.
                       
                      Walden
                       
                      ----- Original Message -----
                      Sent: Thursday, April 19, 2007 12:24 PM
                      Subject: [rest-discuss] RESTful URLs for non-CRUD operations

                      I understand that it's always important to model everything as a
                      resource in a REST system and perform CRUD operations on them (so that
                      GET, POST, PUT and DELETE can fit the bill). But there might be cases
                      where you have to model non-CRUD operations in your REST system - and
                      not all reasons are technical. You customers are used to a certain
                      vocabulary which contains well-known and well-accepted verbs and you
                      simply can't change them to fit the "resource" paradigm.

                      So given this constraint that you absolutely must have non-standard
                      verbs, what's the best way to model them?

                      I have a blog entry on this and would appreciate your suggestions.

                      http://abstractfina l.blogspot. com/2007/ 04/restful- urls-for- non-crud- operations. html

                      Thanks,
                      Keyur



                      __________ NOD32 2208 (20070421) Information __________

                      This message was checked by NOD32 antivirus system.
                      http://www.eset.com
                    Your message has been successfully submitted and would be delivered to recipients shortly.