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

19669Re: [rest-discuss] RESTful Toggle

Expand Messages
  • Nick Gall
    Jul 9, 2014
      Robby, I'd like to know more about the real world need for such an API. Sure, mechanical light switches DID work this way, but do home automation systems really offer a "toggle"? I'm trying to imagine why I would ever want to simply change the state of the lighting in my room, without caring if the result was lights on or lights off. I can't.

      So are you programming a home automation system? If so, do you really need toggle, given my observation above?

      Or is this just a hypothetical question about the generic behavior of toggle and how it maps to REST? If so, then it kind of feels like the perennial, "Can REST do THIS?" questions that skeptics of REST would lob from time to time in the good old REST v WS-STAR WARS days. It kind of reminds me of the old chestnut, "How can I do two-phase commit in REST?"

      Or is your need for toggle behavior truly needed in some other actual domain? If so, could you please tell us a bit more about the domain and it's REAL need for toggle behavior. With such context in mind, we can perhaps help you better map it into a RESTful API.


      -- Nick

      Nick Gall
      Phone: +1.781.325.8370
      Other Contact Info: http://bit.ly/nickgall

      On Tue, Jul 8, 2014 at 5:28 PM, 'Simpson, Robby (GE Energy Management)' robby.simpson@... [rest-discuss] <rest-discuss-noreply@yahoogroups.com> wrote:

      I've been scratching my head over this one for a while and am hoping I can
      get some help.

      Imagine a light switch with one simple resource: /state , where state can
      be "On" or "Off."

      One can PUT to /state , changing /state to either "On" or "Off."
      Similarly, a GET to /state will tell you if the light is currently "On" or

      Where I'm struggling is with a safe "Toggle" mechanism.  That is, if
      /state is "On", change it to "Off" and vice versa.

      I understand that one solution would be to simply perform a GET on /state
      and then PUT the opposite.  However, I am concerned with both the overhead
      and latency this entails as well as the potential for a race condition
      (what if /state changes between the GET and the PUT?).

      Any solution I've looked at thus far seems to violate RESTful principles,
      particularly regarding idempotency.  In short, can one safely toggle?

      Any suggestions?


      Posted by: "Simpson, Robby (GE Energy Management)" <robby.simpson@...>


      Yahoo Groups Links

      <*> To visit your group on the web, go to:

      <*> Your email settings:
          Individual Email | Traditional

      <*> To change settings online go to:
          (Yahoo! ID required)

      <*> To change settings via email:

      <*> To unsubscribe from this group, send an email to:

      <*> Your use of Yahoo Groups is subject to:

    • Show all 36 messages in this topic