Use PATCH instead of PUT for modify.#4
Use PATCH instead of PUT for modify.#4seattlevine wants to merge 1 commit intothwi:masterfrom seattlevine:modifyWithPatch
Conversation
While it is arguable more proper in REST to have modify do a PUT, in tmsh, and therefore iControl REST, modify is a PATCH. For example, do a tmsh modify sys global-settings: only what you set is modified. But do a PUT to /mgmt/tm/sys/global-settings and items you don't set (mgmtDhcp, for example) will be set.
|
Seems like a good enhancement in that it would bring .modify() more in line with tmsh behavior and thus be more intuitive. Are you aware of any use cases for using PUT? I'm wondering if it would be worthwhile to introduce a different verb that uses PUT (maybe 'replace' or 'set'?) or perhaps provide an option to override the HTTP method for 'modify' if there's a compelling reason to do so. Alternatively, PATCH could use a different verb like 'update' or 'append', but this doesn't seem as optimal since it diverges from tmsh. |
|
There likely are use cases for PUT, though I haven't tried it with this library. There are certainly cases where you don't necessarily get what you want when dealing with tmsh transactions (and therefore iControl REST transactions) due to mark and sweep. In these cases, doing a DELETE on an object with array items which are not in a sub-collection (rules of an AFM policy, for example) and a subsequent POST of that item with the same or modified rules fails but works if you use PUT instead of POST. Not sure what happens if you use PATCH here. I tried to come up with a different verb to use for PATCH instead of modifying the existing behavior, but then realized that modify in tmsh really is PATCH. So, a different verb for PUT makes sense. 'replace' is decent since that maps to 'replace-all-with' nicely. |
|
Could you @thwi please merge the commit from @seattlevine? If you don't want to break the original code, what if you add a modify2 function where we have PATCH instead of PUT? // Modify // Modify2 |
While it is arguable more proper in REST to have modify do a PUT,
in tmsh, and therefore iControl REST, modify is a PATCH.
For example, do a tmsh modify sys global-settings: only what you set is
modified. But do a PUT to /mgmt/tm/sys/global-settings and items you don't
set (mgmtDhcp, for example) will be set.