aip-dev / google.aip.dev

API Improvement Proposals. https://aip.dev/
Other
1.1k stars 501 forks source link

AIP-128 appears to be incompatible with AIP-216 #713

Open ekuefler opened 3 years ago

ekuefler commented 3 years ago

AIP-216 says that state transitions should be handled using custom methods, but AIP-128 says that custom methods should be avoided (though AIP-136 excepts "specific declarative-friendly custom methods discussed in other AIPs").

Should AIP-216 specifically discuss state transition methods as declarative-friendly, or should declarative-friendly APIs do state transitions in some other way? https://github.com/aip-dev/google.aip.dev/issues/345 is related.

shaneqld commented 3 years ago

You're correct in that they are incompatible. You should assume that AIP-128 takes precedence if you are designing a declarative-friendly API.

AIP-128 explains:

These tools are declarative: rather than specifying specific actions to take, they specify the desired outcome, with the actions being derived based on the differences between the current landscape and the intended one.

As such, if you want to affect the state of a declarative-friendly resource, you should Update the resource. Not the state directly, but other fields where such a modification triggers your system to perform an action or change state.

Another standard method that can change state is Delete.

...but AIP-128 says that custom methods should be avoided (though AIP-136 excepts "specific declarative-friendly custom methods discussed in other AIPs").

One example of a specific declarative-friendly custom method discussed in another AIP is Undelete, discussed in AIP-164.

Check out this example of a declarative-friendly API by Google.