“Toggle” is by definition not idempodent, because you get a different result each and every time. “Open” and “close” are idempodent, but not safe. The result of a GET request should always be idempodent and safe.
I'd just like to clarify that what you have described here is "safe" rather than "idempotent" [0]. Easy mistake to make, made the same mistake myself, idempotently (that is to say you only make it once ;)
Get, and NOOP, are both "safe" and naturally "idempotent" since the former encompasses the latter.
GET must be safe and idempodent. In the context of http, idempodency basically means that you get the same result for each request with the same url and the same set of parameters.
Toggle should be implemented as post, since it’s neither safe, nor idempodent.
> get the same result for each request with the same url and the same set of parameters.
I think the resource can change externally...so it means that your GET request doesn't change it, but it doesn't have to be the same result every time.
Reading from a database isn’t “side effect free”, neither is reading from a mutable variable.
Given that HTTP requests are supposed to trigger database reads that may return a different result after some time, then “side effect free” would indeed be incorrect.
The litmus test is ... does it always return the same output given the same input? If that can change, the it’s not describing a pure function, but a side effectful one.
And the output of a GET request can and does change.
Speaking of which people here aren’t talking of idempotency in a mathematical sense:
f(f(x)) == f(x)
If you really think about it, GET requests aren’t even idempotent ;-)