I would have thought that pressing an elevator call button is non-idempotent, since it affected something on the backend. It changed state. An elevator button is a POST. I thought POSTs like that that perform an action are non-idempotent.
Where as asking for the current floor is idempotent (i.e. a GET). Do I have this all wrong?
I think you have it wrong. As far as I understand, an operation is idempotent if you can perform it any number of times consecutively (without another operation taking place), and have the resulting state be the same. So for the elevator, you can press it 1 time, or 100 times, and it will have the same result of calling the elevator to your floor, so long as no operation (ex. The elevator arriving at your floor) takes place in between button presses.
I don't agree. Idempotency in terms of REST (or equivalent) is about the effect on the receiver of the call. Pressing the button each time is definitely not idempotent, because it is a change of state of the button.
The fact that the server may choose to ignore this change in terms of the travel of the elevator is not relevant to the change of state of the button transmitted by it being pressed.
...which is weird because in the elevator example, the state isn't being modified. The effect on the receiver, to use their terminology, is always to set the button to "on" or "called" or whatever you want to name it. Hence, the elevator button example is idempotent.
Quick edit: Someone else below makes a good point - in at least one part of the world, a second button press does act as "cancel". Maybe that's the confusion here?
The idempotency in REST is about the State Transfer, not the state itself.
The POST is not idempotent because it transferred a change of state (of the button) between the client and the server. REST is about State Transfer between a client and server.
POST/DELETE send a change of state of a resource.
GET/HEAD/OPTIONS do not.
PUT and PATCH are idempotent iff the server does not change the state of the resource except as the result of the PUT or PATCH.
It is not about the state of a resource on either the client or server, both are free to change that state independently.
Doing a GET on the current state of the button is idempotent because the client doesn't change the state of the button.
But there's nothing to stop the server (ie the elevator electronics) to change the state of the button (show it as "pressed") if something else changes the state (eg, someone in the elevator presses the button for that floor, the button might display as "pressed" on the floor itself).
I think that DELETE is also idempotent. When you call DELETE you are deleting a specific resource. The result is the same if you call DELETE more than once, the resource no longer exists.
Where as asking for the current floor is idempotent (i.e. a GET). Do I have this all wrong?